Rerank API Guide
The Turing Platform's Rerank model ranks a set of documents by relevance to a query, and is widely used in RAG (Retrieval-Augmented Generation), search engine result optimization, and similar scenarios.
Notes:
- The Rerank API is compatible with the Cohere Rerank format
- Supports 100+ languages including Chinese, English, Spanish, French, Portuguese, Japanese, Korean, German, Russian, and Indonesian
- Supports controlling the number of returned documents via the
top_nparameter - Results are returned sorted by relevance score in descending order
- For available models, see Model List
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g. qwen3-rerank |
query | string | Yes | Search query string |
documents | list[string] | Yes | List of documents to rank |
top_n | int | No | Return only the top N ranked documents; returns all by default |
return_documents | bool | No | Whether to include document content in the results |
rank_fields | list[string] | No | Fields to use for ranking (used when documents are dicts) |
max_chunks_per_doc | int | No | Maximum number of chunks per document |
max_tokens_per_doc | int | No | Maximum number of tokens per document |
Response Format
| Field | Type | Description |
|---|---|---|
id | string | Request ID |
results | list | List of ranked results |
results[].index | int | Index of the document in the original list |
results[].relevance_score | float | Relevance score of the document |
results[].document | object | Document content (returned when return_documents=true) |
meta | object | Metadata (includes token usage, etc.) |
CURL
curl $TURING_BASE_URL/rerank \
-H "Authorization: Bearer $TURING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-rerank",
"query": "What is a text reranking model",
"documents": [
"Text reranking models are widely used in search engines and recommendation systems, ranking candidate texts by textual relevance",
"Quantum computing is a cutting-edge field of computational science",
"Advances in pre-trained language models have brought new developments to text reranking models"
],
"top_n": 2
}'
Response Example
{
"id": "rerank-xxxxx",
"results": [
{
"index": 0,
"relevance_score": 0.98,
"document": {
"text": "Text reranking models are widely used in search engines and recommendation systems, ranking candidate texts by textual relevance"
}
},
{
"index": 2,
"relevance_score": 0.85,
"document": {
"text": "Advances in pre-trained language models have brought new developments to text reranking models"
}
}
],
"meta": {
"billed_units": {
"total_tokens": 128
}
}
}
See also
- API Reference → Rerank — Complete request/response schema with Try-It and multi-language examples (cURL / Python / Node.js / Java)
- Model List (Rerank) — Available models and pricing