Skip to main content

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_n parameter
  • Results are returned sorted by relevance score in descending order
  • For available models, see Model List

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g. qwen3-rerank
querystringYesSearch query string
documentslist[string]YesList of documents to rank
top_nintNoReturn only the top N ranked documents; returns all by default
return_documentsboolNoWhether to include document content in the results
rank_fieldslist[string]NoFields to use for ranking (used when documents are dicts)
max_chunks_per_docintNoMaximum number of chunks per document
max_tokens_per_docintNoMaximum number of tokens per document

Response Format

FieldTypeDescription
idstringRequest ID
resultslistList of ranked results
results[].indexintIndex of the document in the original list
results[].relevance_scorefloatRelevance score of the document
results[].documentobjectDocument content (returned when return_documents=true)
metaobjectMetadata (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