For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
  • API Guides
    • Overview
    • Streaming
    • Embeddings
    • Limits
    • Authentication
    • Parameters
    • Errors and Debugging
  • API Reference
      • POSTSubmit a rerank request
LogoLogo
ModelsChatRankingsDocs
API ReferenceRerank

Submit a rerank request

POST
https://openrouter.ai/api/v1/rerank
POST
/api/v1/rerank
$curl -X POST https://openrouter.ai/api/v1/rerank \
> -H "Authorization: Bearer <token>" \
> -H "Content-Type: application/json" \
> -d '{
> "documents": [
> "Paris is the capital of France.",
> "Berlin is the capital of Germany."
> ],
> "model": "cohere/rerank-v3.5",
> "query": "What is the capital of France?",
> "top_n": 3
>}'
1{
2 "model": "cohere/rerank-v3.5",
3 "results": [
4 {
5 "document": {
6 "text": "Paris is the capital of France."
7 },
8 "index": 0,
9 "relevance_score": 0.98
10 }
11 ],
12 "id": "gen-rerank-1234567890-abc",
13 "usage": {
14 "search_units": 1,
15 "total_tokens": 150
16 }
17}
Submits a rerank request to the rerank router
Was this page helpful?
Previous

Submit a video generation request

Next
Built with

Authentication

AuthorizationBearer
API key as bearer token in Authorization header

Request

Rerank request input
documentslist of stringsRequired
The list of documents to rerank
modelstringRequired
The rerank model to use
querystringRequired
The search query to rerank documents against
providerobjectOptional
Provider routing preferences for the request.
top_nintegerOptional>=1
Number of most relevant documents to return

Response

Rerank response
modelstring
The model used for reranking
resultslist of objects
List of rerank results sorted by relevance
idstring

Unique identifier for the rerank response (ORID format)

providerstring
The provider that served the rerank request
usageobject
Usage statistics

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
404
Not Found Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error
503
Service Unavailable Error