Skip to main content
The /v1/rerank endpoint takes a search query and a list of documents, then returns the documents ordered by their relevance to the query. Each result includes a relevance score you can use to filter or threshold results before passing them to a language model. Reranking is commonly used as a second-stage retrieval step in RAG pipelines to improve the quality of context sent to a model.

Request parameters

string
required
The reranking model to use. Use the list models endpoint to find available reranking model IDs.
string
required
The search query against which the documents are ranked.
string[]
required
An array of document strings to rank. Each string is treated as a candidate document. The order of this array determines the index values in the response.
integer
The maximum number of results to return. When omitted, all documents are returned ranked by relevance score.

Response fields

array
An array of ranked result objects sorted from highest to lowest relevance score.

Example

Request

Response