API reference
Rerank
POST /v2/rerank reorders candidate documents — the precision stage of RAG retrieval.
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
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | Rerank model id, see Models |
query | string | Yes | Query text |
documents | array | Yes | Candidates (strings, or objects with text) |
top_n | integer | No | Return 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 —.