Create a Rerank
Reranks documents by relevance to a query. Supports text, image, and video content.
Set the header 'Authorization: Bearer {your API key}' for authentication
In: header
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.
"BAAI/bge-reranker-v2-m3"The search query. Length must be ≥ 1.
1 <= length"Apple"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.
Item: A single document item in the rerank input list.
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.
1 <= length"Please rerank the documents based on the query."Number of most relevant documents or indices to return. Must be ≥ 1.
1 <= value4If false, the response does not include document text; if true, it includes the input document text. Default is false.
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.
10241 <= valueNumber 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.
value <= 80The model name for multimodal reranking. Support models: Qwen/Qwen3-VL-Reranker-8B
"Qwen/Qwen3-VL-Reranker-8B"The search query. Supports text string or content object.
- Text query: a plain string
- Image query:
{"image": "https://example.com/image.jpg"}or base64
Length must be ≥ 1.
The list of documents to be ranked. Each item can be a text string or a content object.
- Text document: a plain string
- Text object:
{"text": "document text"} - Image object:
{"image": "https://example.com/image.jpg"}or base64
At least 1 document is required.
["apple","banana","fruit","vegetable"]Item: A single document item in the VL rerank input list.
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.
1 <= length"Please rerank the documents based on the query."Number of most relevant documents or indices to return. Must be ≥ 1.
1 <= value4If false, the response does not include document text; if true, it includes the input document text. Default is false.
Maximum number of chunks generated from within a document. Must be ≥ 1, default is 1024.
10241 <= valueNumber of token overlaps between adjacent chunks when documents are chunked. Must be between 0 and 80.
value <= 80Response Body
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.
TypeScript Definitions
Use the response body type in TypeScript.
Unique identifier for the response.
"rerank-20240115-abc123def456"List of reranked results sorted by relevance score.
Item: A single rerank result.
Metadata about the rerank response.
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
}'
import os
import requests
url = "https://api.siliconflow.cn/v1/rerank"
headers = {
"Authorization": f"Bearer {os.environ.get('SILICONFLOW_API_KEY')}",
"Content-Type": "application/json"
}
payload = {
"model": "Qwen/Qwen3-VL-Reranker-8B",
"query": {"image": "https://example.com/query-image.jpg"},
"documents": [
{"image": "https://example.com/doc1.jpg"},
"A relevant text document..."
],
"max_chunks_per_doc": 512
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
curl -X POST https://api.siliconflow.cn/v1/rerank \
-H "Authorization: Bearer $SILICONFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-Reranker-8B",
"query": "Find the most relevant technical docs",
"documents": ["doc1", "doc2", "doc3"],
"instruction": "Prefer recently published content",
"overlap_tokens": 20
}'
{
"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
}
}
}{
"code": 20012,
"message": "string",
"data": "string"
}"Invalid token""Forbidden""404 page not found"{
"message": "Request was rejected due to rate limiting. If you want more, please contact contact@siliconflow.cn. Details:TPM limit reached.",
"data": "string"
}{
"code": 50505,
"message": "Model service overloaded. Please try again later.",
"data": "string"
}"string"Create a Embedding POST
Converts input content into embedding vectors. Supports text, image URL/base64, and mixed lists.
Image Generation POST
Creates an image response for the given prompt. The URL for the generated image is valid for one hour. Please make sure to download and store it promptly to avoid any issues due to URL expiration.