Skip to main content
POST
/
rerank
curl -X POST https://api.siliconflow.cn/v1/rerank \ -H "Authorization: Bearer $SILICONFLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "BAAI/bge-reranker-v2-m3", "query": "Apple", "documents": ["apple", "banana", "fruit", "vegetable"], "return_documents": true, "top_n": 4 }'
{
  "id": "rerank-20240115-abc123def456",
  "results": [
    {
      "index": 1,
      "document": {
        "text": "深度学习是机器学习的子集..."
      },
      "relevance_score": 0.85
    }
  ],
  "meta": {
    "tokens": {
      "input_tokens": 150,
      "output_tokens": 10,
      "image_tokens": 0
    },
    "billed_units": {
      "input_tokens": 150,
      "output_tokens": 10,
      "image_tokens": 0,
      "search_units": 1,
      "classifications": 0
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.siliconflow.cn/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Use the following format for authentication: Bearer

Body

application/json

Compatible with two request formats:

  • Classic Rerank: text query with text documents
  • Multimodal Rerank: supports image/video content in query and documents

Note: OpenAPI cannot automatically route schemas based on model. Choose parameters according to model capabilities.

model
string
required

Corresponding Model Name. To better enhance service quality, we will make periodic changes to the models provided by this service, including but not limited to model on/offlining and adjustments to model service capabilities. We will notify you of such changes through appropriate means such as announcements or message pushes where feasible. For a complete list of available models, please check the Models.

Example:

"BAAI/bge-reranker-v2-m3"

query
string
required

The search query. Length must be ≥ 1.

Minimum string length: 1
Example:

"Apple"

documents
required

The list of documents to be ranked. Supports the following formats:

  • A single text string
  • An array of text strings At least 1 document is required.
Example:

"apple"

instruction
string

The instruction for the reranker. Only supported by Qwen/Qwen3-Reranker-8B, Qwen/Qwen3-Reranker-4B, Qwen/Qwen3-Reranker-0.6B. Length must be ≥ 1.

Minimum string length: 1
Example:

"Please rerank the documents based on the query."

top_n
integer

Number of most relevant documents or indices to return. Must be ≥ 1.

Required range: x >= 1
Example:

4

return_documents
boolean
default:false

If false, the response does not include document text; if true, it includes the input document text. Default is false.

max_chunks_per_doc
integer
default:1024

Maximum number of chunks generated from within a document. Long documents are divided into multiple chunks for calculation, and the highest score among the chunks is taken as the document's score. Only BAAI/bge-reranker-v2-m3, Pro/BAAI/bge-reranker-v2-m3, netease-youdao/bce-reranker-base_v1 support this field. Must be ≥ 1, default is 1024.

Required range: x >= 1
overlap_tokens
integer

Number of token overlaps between adjacent chunks when documents are chunked. Only BAAI/bge-reranker-v2-m3, Pro/BAAI/bge-reranker-v2-m3, netease-youdao/bce-reranker-base_v1 support this field. Must be between 0 and 80.

Required range: 0 <= x <= 80

Response

The response from the model. The response header contains the x-siliconcloud-trace-id field, which serves as a unique identifier for tracing requests, facilitating log queries and issue troubleshooting.

id
string
required

Unique identifier for the response.

Example:

"rerank-20240115-abc123def456"

results
object[]
required

List of reranked results sorted by relevance score.

meta
object

Metadata about the rerank response.