Rerank
Rerank a set of documents against a query, returning results ordered by relevance — typically used to refine retrieval results.
Basics
MethodPOST
Endpointhttps://koprouter.kopglobal.com/v1/rerank
AuthenticationAuthorization: Bearer sk-...
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Rerank model ID |
query |
string | Yes | Query text |
documents |
array | Yes | Array of document texts to rank |
top_n |
number | No | Return the top N results; default returns all |
Example Request
curl https://koprouter.kopglobal.com/v1/rerank \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"query": "How to reset my password",
"documents": [
"Recovering your account",
"Steps to change your login password",
"Viewing billing details"
],
"top_n": 2
}'
Example Response
{
"id": "rerank-abc123",
"model": "MODEL_ID",
"results": [
{ "index": 1, "relevance_score": 0.92 },
{ "index": 0, "relevance_score": 0.71 }
]
}