Rerank documents
Rank documents by relevance.
/model/v1/rerank● SupportedRequest body
modelstring必填Rerank model id; list candidates with listModels?type=reranking. Router support (supported): Verified to take effect.
Verified to take effect.
querystring必填Query to rank the documents against, at least 1 character. Router support (supported): Verified to take effect.
Verified to take effect.
documentsarray必填◐ Partially supportedDocuments to rank, as plain strings, at least one. Router support (partial): Only string arrays are supported; object arrays return 400.
Only string arrays are supported; object arrays return 400.
top_ninteger可选Number of best results to return, at least 1; omit it to return every document. Router support (supported): Controls returned result count; zero returns 400.
Controls returned result count; zero returns 400.
return_documentsboolean可选○ Unsupportedbge-reranker-base returns 400; only model, query, documents and top_n are supported.
max_tokens_per_docinteger可选○ Unsupportedbge-reranker-base returns 400; only model, query, documents and top_n are supported.
rank_fieldsarray可选○ Unsupportedbge-reranker-base returns 400; only model, query, documents and top_n are supported.
max_chunks_per_docinteger可选○ Unsupportedbge-reranker-base returns 400; only model, query, documents and top_n are supported.
userstring可选○ Unsupportedbge-reranker-base returns 400; only model, query, documents and top_n are supported.
Returns
200
Standard request fields; unrepresentable parameters return input_not_representable.
Platform errors (auth, rate limits, validation) and OCR errors use problem+json; other model call errors follow the endpoint's own format (OpenAI or Anthropic) — see error codes
Response
HTTP 200
Cohere v2 rerank results.
application/json
| Name | Type | Description |
|---|---|---|
| results | array<object> | Results ordered by relevance, best first. Each entry points back to a document with `index`. |
| results[].index | integer | Zero-based position of the document in the request `documents` array. |
| results[].relevance_score | number | Relevance of the document to the query, from 0 to 1; larger is more relevant. |