tokrouterdocs
API reference

Rerank

POST /v2/rerank reorders candidate documents — the precision stage of RAG retrieval.

.mdOpen in Claude
POST https://api.tokrouter.dev/v2/rerank
Authorization: Bearer sk-…
curl https://api.tokrouter.dev/v2/rerank \
  -H "Authorization: Bearer $TOKROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-rerank",
    "query": "What is SSE?",
    "documents": [
      "SSE is server-sent events, a one-way HTTP stream.",
      "WebSocket is a full-duplex protocol.",
      "Nice weather today."
    ],
    "top_n": 2
  }'

Request fields

FieldTypeRequiredNotes
modelstringYesRerank model id, see Models
querystringYesQuery text
documentsarrayYesCandidates (strings, or objects with text)
top_nintegerNoReturn only the top N

Response

{
  "results": [
    {"index": 0, "relevance_score": 0.93},
    {"index": 1, "relevance_score": 0.21}
  ],
  "usage": {"total_tokens": 48}
}

index points at the position in documents, ordered by descending relevance_score.

Billing

Rerank models have input tokens only — the output column in the price table shows —.