Skip to content

Rerank (reorder documents by relevance) ​

POST /v1/rerank reorders a set of candidate documents by their relevance to a query; it is used for re-ranking RAG retrieval results and for search result optimization. It uses the Cohere format — Cohere SDK compatible.

1. Request ​

bash
curl https://token.yaoshu.cc/v1/rerank \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<rerank-model>",
    "query": "What is natural language processing",
    "documents": ["NLP is a field of AI...", "Computer vision is..."],
    "top_n": 3
  }'
ParameterTypeRequiredDescription
modelstring✅Rerank model name, as returned by GET /v1/models
querystring✅Query text
documentsstring[]✅List of candidate documents
top_nnumberNoReturn the top N results

2. Response ​

Standard Cohere structure: results[] contains index (the index of the corresponding input document) and relevance_score (relevance score; higher means more relevant), already sorted by score in descending order.

3. Billing ​

Metered by token (query + documents combined). Unit prices are per the model pricing page in the Console.

Public documentation for platform users