Reranking
API reference for Mixedbread's Reranking endpoint. This documentation covers request parameters, response structure, and includes examples for reordering documents based on their relevance to a given query.
POST/v1/reranking
This endpoint sorts a list of documents based on their relevance to a given query. It returns a relevance score for each document, which you can use to enhance search results and recommendations.
Request Body
- model
model
- Type
- string
- Required or Optional
- required
- Description
The model to be used for reranking the documents.
- Must be a valid model. Refer to our supported models.
- query
query
- Type
- string
- Required or Optional
- required
- Description
The query to rerank the documents for.
- Max 256 Tokens.
- input
input
- Type
- string[] | object[]
- Required or Optional
- required
- Description
The input documents to be reranked. These can either be plain strings or structured objects.
- Between 1-1000 items.
- Documents exceeding token limit will be truncated.
- rank fields
rank fields
- Type
- string[]
- Required or Optional
- optional
- Description
Specifies the fields within the objects that should be considered for ranking.
- Must adhere to JMESPath or a similar JSON query language syntax.
- top_k
top_k
- Type
- integer
- Required or Optional
- optional
- Description
The number of top documents to return after reranking. If not provided, all input documents will be returned.
- Between 1 and the number of passed documents
- Default is the number of input documents
- return_input
return_input
- Type
- boolean
- Required or Optional
- optional
- Description
Option to include the original input documents in the response. Default is false.
Response Body
- model
model
- Type
- string
- Required or Optional
- required
- Description
The reranking model used, which can be one of our hosted models or a custom fine-tuned model.
- top_k
top_k
- Type
- integer
- Required or Optional
- required
- Description
The number of top documents returned after reranking.
- return_input
return_input
- Type
- boolean
- Required or Optional
- required
- Description
Indicates whether the original input documents are included in the response.
- object
object
- Type
- string
- Required or Optional
- required
- Description
The type of the returned object. Always "list".
- data
data
- Type
- RankedDocument[]
- Required or Optional
- required
- Description
A list of the reranked documents.
- data[x].index
data[x].index
- Type
- integer
- Required or Optional
- required
- Description
The index of the document in the original input list.
- data[x].score
data[x].score
- Type
- number
- Required or Optional
- required
- Description
The relevance score of the document to the query. Higher values indicate higher relevance.
- data[x].input
data[x].input
- Type
- object
- Required or Optional
- optional
- Description
The original input document, if
return_input
was set to true.
- data[x].object
data[x].object
- Type
- string
- Required or Optional
- required
- Description
The type of the returned object. Always "text_document".
- usage
usage
- Type
- object
- Required or Optional
- required
- Description
Information about API usage for this request.
- usage.prompt_tokens
usage.prompt_tokens
- Type
- integer
- Required or Optional
- required
- Description
The number of tokens in the query and input documents.
- usage.total_tokens
usage.total_tokens
- Type
- integer
- Required or Optional
- required
- Description
The total tokens used for reranking, including the model's overhead.