Rerank documents

Sort candidate `documents` by semantic relevance to a `query`. Returns each document's original index plus a 0-1 relevance score (higher = more relevant). Score is relative to the request and not comparable across requests. Built for RAG and search refinement: feed in the top-N hits from your vector store / BM25 / hybrid retriever, and the model returns a tighter, better-ordered shortlist.

Authentication

AuthorizationBearer

Pass your EmpirioLabs API key as a bearer token. The Anthropic-style x-api-key header is also accepted on every endpoint.

Request

This endpoint expects an object.
modelstringRequired
querystringRequired
Query text. Max 4,000 tokens.
documentslist of stringsRequired
Candidate documents to sort. Max 500 items, each up to 4,000 tokens.
top_nintegerOptional1-500

Number of top-ranked documents to return. Defaults to all.

instructstringOptional

Custom English instruction guiding the sort. Defaults to a Q&A retrieval policy. Pass "Retrieve semantically similar text." for similarity sorting.

return_documentsbooleanOptionalDefaults to false
When true, return the original document text alongside each result.

Response

Sorted relevance scores.
outputobject
usageobject
request_idstring