Skip to main content
The /v1/rerank endpoint takes a query and a list of documents, then returns those documents sorted by relevance score. Reranking is typically used as a second-stage filter after an initial vector search retrieves a broad set of candidate documents. The reranker produces more precise relevance signals than embedding similarity alone, which improves the quality of context passed to a language model.

Authentication

Include your API key in every request:

Send a rerank request

Provide a query string, a documents array, and a model. TokModel returns the documents re-ordered from most to least relevant, each annotated with a relevance_score.

Example response

The results array is sorted by relevance_score in descending order. The index field refers to the position of the document in the original input array.
Use the relevance_score to decide how many documents to forward to the language model. A common pattern is to keep only results above a threshold (e.g. 0.5) or to take the top-k regardless of score.

Key parameters

Use reranking in a RAG pipeline

A typical RAG pipeline retrieves more documents than it can fit in the context window, then reranks them to keep only the most relevant ones.
python
Retrieve 20–50 candidates from your vector store and pass them to the reranker, then use only the top 3–5 results as context. This pattern consistently outperforms passing raw vector search results directly to the model.