Skip to content

Rerank

Takes a query and a list of documents and re-sorts the documents by relevance. In RAG systems it's used to rank candidate documents returned from search, from best to worst.

POST/v1/rerank

Request parameters

FieldTypeRequiredDescription
modelstringRerank model (e.g. verirerag)
querystringSearch query
documentsarrayList of texts to rank
top_nintegerReturn only the top N results
return_documentsbooleanAlso return the document text in results
max_chunks_per_docintegerMax chunks per document

Example

bash
curl https://app.qevron.ai/v1/rerank \
  -H "Authorization: Bearer $QEVRON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "verirerag",
    "query": "How does Qevron authenticate?",
    "documents": [
      "Qevron authenticates requests with a Bearer token.",
      "The weather in Istanbul is rainy today.",
      "Embedding turns text into a vector."
    ],
    "top_n": 2,
    "return_documents": true
  }'
python
import httpx

resp = httpx.post(
    "https://app.qevron.ai/v1/rerank",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "verirerag",
        "query": "How does Qevron authenticate?",
        "documents": [
            "Qevron authenticates requests with a Bearer token.",
            "The weather in Istanbul is rainy today.",
            "Embedding turns text into a vector.",
        ],
        "top_n": 2,
        "return_documents": True,
    },
)
print(resp.json())

Response

json
{
  "id": "rerank-...",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.987,
      "document": { "text": "Qevron authenticates requests with a Bearer token." }
    },
    {
      "index": 2,
      "relevance_score": 0.142,
      "document": { "text": "Embedding turns text into a vector." }
    }
  ],
  "meta": { "tokens": { "input_tokens": 48 } }
}
FieldDescription
results[].indexOriginal position in the input
results[].relevance_scoreRelevance score (higher = more relevant)
results[].documentDocument text if return_documents: true

Results are returned in descending score order.

Qevron — AI gateway. Arpanet / OpenAI / Anthropic / Gemini compatible.