Qwen3 Reranker 8B API
AvailableQwen3 Reranker 8B reads a query together with each candidate passage and returns a relevance score from 0 to 1. Used after an embedding search, it lifts the passages that actually answer the question above the ones that merely share words with it. The request shape follows the common rerank format: query, documents, top_n.
Quickstart
Set INFERENCE_API_KEY to your key from the API Keys page, then run:
curl https://api.inferenceapis.com/v1/rerank \
-H "Authorization: Bearer $INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-Reranker-8B",
"query": "What is the capital of France?",
"documents": ["Bananas are yellow.", "Paris is the capital of France.", "Berlin is in Germany."],
"top_n": 2
}'
import os, requests
resp = requests.post(
"https://api.inferenceapis.com/v1/rerank",
headers={"Authorization": f"Bearer {os.environ['INFERENCE_API_KEY']}"},
json={
"model": "Qwen/Qwen3-Reranker-8B",
"query": "What is the capital of France?",
"documents": ["Bananas are yellow.", "Paris is the capital of France.", "Berlin is in Germany."],
"top_n": 2,
},
timeout=60,
)
for r in resp.json()["results"]:
print(r["index"], round(r["relevance_score"], 4))
const resp = await fetch("https://api.inferenceapis.com/v1/rerank", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.INFERENCE_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
model: "Qwen/Qwen3-Reranker-8B",
query: "What is the capital of France?",
documents: ["Bananas are yellow.", "Paris is the capital of France.", "Berlin is in Germany."],
top_n: 2,
}),
});
console.log((await resp.json()).results);
When to use it
- Second-stage ranking in RAG: fetch 20 to 100 candidates with embeddings, then keep the best few
- First-stage retrieval over a whole corpus; that is what embeddings are for
What it costs in practice
| Workload | Cost |
|---|---|
| 10,000 searches, each reranking 20 passages of 200 tokens | $2.80 |
| 1 million searches, each reranking 20 passages of 200 tokens | $280 |
| 10,000 searches, each reranking 100 passages of 200 tokens | $14.00 |
Computed from the live rate below. There is no subscription or minimum; new accounts start with free credit.
Endpoint
Content-Type: application/json
/openai/v1/… is accepted too, so Groq-style base URLs work with only the host changed.
Model IDs and aliases
Send any of these as model; they all resolve to this model and bill at its rate.
| ID | Note |
|---|---|
Qwen/Qwen3-Reranker-8B | Canonical |
qwen3-reranker-8b | Alias |
Request body
| Parameter | Type | Description |
|---|---|---|
model required |
string | Model ID: Qwen/Qwen3-Reranker-8B |
query required |
string | The search query. |
documents required |
array | Up to 1,000 candidate texts, as strings or {"text": "..."} objects. |
top_n |
integer | Return only the best n results. Default: all, sorted by score. |
return_documents |
boolean | Include each document's text in the results. |
Response
{
"object": "list",
"model": "Qwen/Qwen3-Reranker-8B",
"results": [
{ "index": 1, "relevance_score": 0.978 },
{ "index": 2, "relevance_score": 0.00002 }
],
"usage": { "total_tokens": 251 }
}
Pricing
| Price | $0.07 / 1M input tokens |
| Billing | Pay as you go from prepaid credits. No subscription, no daily request or token cap. See all pricing. |
Notes
- Billing counts the tokens the model reads: the query is read once per document, plus a short instruction, so a request costs more tokens than the raw text suggests. The response reports the count in
usage.total_tokens.
Errors
Errors use the OpenAI envelope: {"error": {"message", "type", "code"}}. 401 missing or invalid key · 402 insufficient_balance · 404 model_not_found · 503 model_unavailable · 502 backend error, safe to retry. Full table with what to retry: API documentation. Errors from other providers: provider error reference.
