Skip to content
Zabio is in beta: models, prices and features can change. Tell us what breaks at hello@zabio.ai.

Rerank

POST /v1/rerank scores a list of documents against a query and returns them ordered by relevance, highest first. Use it after a search or an embeddings lookup, to put the passages that best answer the question at the top before they go into a prompt.

The request and the answer take Cohere’s v1 rerank shape, which Together AI, Jina AI and Alibaba Cloud’s compatible endpoint also use, and which OpenRouter’s SDKs send. Rerank models are always named: there is no auto for rerank, and a call never falls back to another model, because the scores of two models do not compare. The key needs the embeddings scope, which keys have by default.

Model Vendor Context window (tokens) Price (USD per million input tokens)
qwen3-reranker-0.6b deepinfra 32,768 0.01
qwen3-reranker-4b deepinfra 32,768 0.025
qwen3-reranker-8b deepinfra 32,768 0.05

GET /v1/models lists them with zabio.kind set to rerank. They are Qwen’s open-weight Qwen3 Reranker models, served by DeepInfra and processed with no guaranteed location (see the privacy page). Prices are provider list prices; the plan fee applies on top (see Billing).

Terminal window
curl https://api.zabio.ai/v1/rerank \
-H "Authorization: Bearer insert your zabio.ai key here" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-reranker-8b",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital of Nevada.",
"Washington, D.C. is the capital of the United States.",
"Capital punishment exists in some states."
],
"top_n": 2,
"return_documents": true
}'
Field Notes
model required; one of the ids above
query required; the text the documents are ranked against, 6,000 characters at most
documents required; 1 to 1,000 documents, each a string or an object whose text is a string (its other keys are not ranked), 32,000 characters at most each and 1,500,000 characters in all with the query
top_n optional; how many results to return, at least 1. Above the number of documents, or left out, returns all of them
top_k optional; another name for top_n (Voyage AI’s)
return_documents optional, default false; true adds each result’s text
zabio optional; {"guard": "model"} asks for the AI Firewall’s model check on the documents returned (below)
stream, store accepted only as false: an answer comes whole, and nothing is stored

These are refused with 400 and the field’s name, so that no document is ranked differently than you asked: rank_fields, max_chunks_per_doc, max_tokens_per_doc, a document that is empty, null or has no text string, and any field not in the table. model: "auto" and the auto/... lines are refused with 400 invalid_value.

{
"id": "call_01J...",
"model": "qwen3-reranker-8b",
"results": [
{"index": 1, "relevance_score": 0.9981, "document": {"text": "Washington, D.C. is the capital of the United States."}},
{"index": 0, "relevance_score": 0.0312, "document": {"text": "Carson City is the capital of Nevada."}}
],
"meta": {"billed_units": {"input_tokens": 196}},
"zabio": {"call_id": "call_01J...", "vendor": "deepinfra", "model_served": "qwen3-reranker-8b", "cost_micros": 10, "tokens_estimated": false}
}

index is the document’s position in your documents. relevance_score is between 0 and 1, and results with the same score keep the order you sent. document appears only with return_documents.

A reranker reads each document together with the query, so a call is billed by the input tokens the vendor counts for every pair: the query, the document and a fixed frame of about 70 tokens each. One query of 60 characters beside 100 documents of 300 characters counted 15,570 tokens on DeepInfra: about 0.00016 USD on qwen3-reranker-0.6b and 0.00078 USD on qwen3-reranker-8b, before the plan fee. meta.billed_units.input_tokens is the count billed. If the vendor returned no count, Zabio bills a lower estimate and says so in zabio.tokens_estimated.

A call counts its estimated input tokens against the key’s tokens per minute limit: about 70 a document plus the text over four. A call over the key’s limit (200,000 by default) is refused with 429 until the limit is raised.

Before the call, Zabio sets aside on your balance an amount that the call cannot exceed, and releases what it did not use when the call ends. A balance too low for it is refused with 402, and nothing is sent.

Documents you rerank are usually text from outside, on its way into a prompt. A reranker is no defense against prompt injection: a document that claims to be the most relevant one can rank first. So Zabio reads the documents it returns, the top top_n, and reports what it finds in zabio.guard, as POST /v1/guard/check reports a check. Each detection’s item and path name the document by its index in your request. Zabio never drops, rewrites or reorders a document: what to do with a flagged one is your call.

  • The patterns are free and follow your key’s guard setting: under any action but off they read the documents returned. On rerank, block and redact report as tag does: no document is blocked or masked.
  • The model check runs only when the request asks with "zabio": {"guard": "model"}, at the firewall’s price per token checked (see Billing), on a separate line from the call. It reads at most 64 documents, so a request that asks for it with more than 64 results is refused with 400 on top_n.
  • Documents beyond the firewall’s limit of 1 MB of text a call are listed in zabio.guard.unchecked with the reason size_limit, never passed as clean.

Zabio stores the call’s metadata: the model, the token count, the cost and the latency. The query and the documents are never written to a log. With body logging on for the key, the query and the documents are stored encrypted with the call, and the results as indexes and scores.

From What to change
Cohere (v1) the base URL, the key and the model id. rank_fields and max_chunks_per_doc are refused
OpenRouter the base URL and the key. Use Zabio’s model id: qwen3-reranker-8b, not qwen/qwen3-reranker-8b
Together AI, Jina AI the base URL, the key and the model id
Voyage AI the base URL, the key and the model id. top_k works as top_n; the results are in results, not data
Status code When
400 invalid_value a field is missing, of the wrong type or over a limit; auto as the model; the model check asked for with more than 64 results
400 unknown_parameter a field the endpoint does not take
400 unsupported_for_model rank_fields, max_chunks_per_doc, max_tokens_per_doc, stream: true or store: true; or the model is not a rerank model
402 insufficient_credits the balance cannot cover the amount set aside for the call
403 insufficient_scope the key lacks the embeddings scope
404 model_not_found not a model, or not allowed for the key
429 rate_limit_exceeded the key’s requests or tokens per minute limit