curl --request POST \
--url https://api.fireworks.ai/inference/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "What is machine learning?",
"documents": [
"Machine learning is a subset of AI.",
"The weather is sunny today."
],
"model": "accounts/fireworks/models/qwen3-reranker-8b",
"top_n": 2,
"return_documents": true,
"task": "Given a web search query, retrieve relevant passages that answer the query"
}
'{
"object": "list",
"model": "<string>",
"data": [
{
"index": 123,
"relevance_score": 0.5,
"document": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}Rerank documents for a query using relevance scoring
curl --request POST \
--url https://api.fireworks.ai/inference/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "What is machine learning?",
"documents": [
"Machine learning is a subset of AI.",
"The weather is sunny today."
],
"model": "accounts/fireworks/models/qwen3-reranker-8b",
"top_n": 2,
"return_documents": true,
"task": "Given a web search query, retrieve relevant passages that answer the query"
}
'{
"object": "list",
"model": "<string>",
"data": [
{
"index": 123,
"relevance_score": 0.5,
"document": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The search query to use for reranking documents.
"What is machine learning?"
A list of documents to rerank. Each document is a string.
1[
"Machine learning is a subset of AI.",
"The weather is sunny today."
]The name of the reranker model to use.
"accounts/fireworks/models/qwen3-reranker-8b"
The number of most relevant documents to return. If not specified, all documents are returned.
x >= 1Whether to return the document text in the response. Defaults to true.
Optional task description to guide the reranking process.
"Given a web search query, retrieve relevant passages that answer the query"
OK
The object type, which is always "list".
list The name of the model used for reranking.
The list of reranked documents, ordered by relevance score (highest first).
Show child attributes
The original index of the document in the input array.
The relevance score between 0 and 1, with higher scores indicating greater relevance.
0 <= x <= 1The document text. Only included if return_documents is true.
Was this page helpful?