Reorder a set of documents by relevance to a query using rerank models.
The rerank endpoint scores a list of documents against a query and returns them ordered by relevance. Use it as the second stage of a retrieval pipeline — pull candidates with embeddings or keyword search, then rerank to surface the best matches.
POST https://opendunes.com/v1/rerank| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A rerank model slug — filter the catalog with ?modality=rerank |
query | string | Yes | The search query to score documents against |
documents | array | Yes | Documents to rank (min 1). Each item is a string, or an object with a text field |
top_n | integer | No | Return only the top N results (default: all, ordered) |
curl https://opendunes.com/v1/rerank \
-H "Authorization: Bearer $OPENDUNES_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cohere/rerank-v3.5",
"query": "What is the capital of Algeria?",
"documents": [
"Oran is a major coastal city in the northwest.",
"Algiers is the capital and largest city of Algeria.",
"The Sahara covers most of southern Algeria."
],
"top_n": 2
}'Each result carries the original index into your documents array and a relevance_score, sorted highest-first:
{
"results": [
{ "index": 1, "relevance_score": 0.98 },
{ "index": 0, "relevance_score": 0.21 }
]
}Rerank is billed per search unit (usage.search_units, falling back to total_tokens). Note that some providers do not expose a rerank price in the model feed, in which case the catalog shows "—" rather than "Free" — see the pricing reference.
GET https://opendunes.com/api/models?modality=rerank