A rerank model re-scores documents returned by initial retrieval, surfacing the most relevant results at the top.
Model overview
- Singapore
- Beijing
Model | Max documents | Max input tokens per item | Max input tokens per request | Supported languages | Scenarios |
|---|---|---|---|---|---|
qwen3-rerank | 500 | 4,000 | 120,000 | Over 100 major languages, such as Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, and Russian |
|
- Max input tokens per item: Maximum tokens per query or document. Exceeding this limit triggers truncation, which may reduce ranking accuracy.
- Max documents: Maximum documents per request. For qwen3-vl-rerank, the limit varies by document type (text, image, video, or mixed).
- Max input tokens per request: Calculated as
Query Tokens × Number of documents + Total document tokens. Must not exceed the per-request limit.
Input limitations
Model | Image | Video |
|---|---|---|
qwen3-vl-rerank | JPEG, PNG, WEBP, BMP, TIFF, ICO, DIB, ICNS, and SGI (URL or Base64 supported) | MP4, AVI, and MOV (URL only) |
Prerequisites
Obtain an API key and set the API key as an environment variable. To use the SDK: install the DashScope SDK.
HTTP
Each model uses a different endpoint:
- qwen3-rerank:
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-api/v1/reranks - qwen3-vl-rerank / gte-rerank-v2:
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank
{WorkspaceId} with your actual workspace ID.
The two APIs differ in request body structure and response format. See the request and response examples for each model.
RequestRequest headersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Request bodymodelstring (Required)The model name. Supported values: qwen3-rerank, gte-rerank-v2, qwen3-vl-rerank.input object (Required)Input content.For
Properties query string | object (Required)Query text (max 4,000 tokens).qwen3-vl-rerank supports two query formats:
array (Required)Candidate documents to sort. Each element is a string.qwen3-vl-rerank accepts a dictionary or string per element: {"modality type": "text/image URL/video URL"}. Supported types: text, image, video.
object (Optional)Optional parameters.For
Properties top_n int (Optional)Number of top-ranked documents to return. Default: all documents. Values exceeding total documents return all.return_documents bool (Optional)Whether to include document text in results. Default: false. Supported models: gte-rerank-v2, qwen3-vl-rerank.instruct string (Optional)Custom sorting instruction. Applies to qwen3-rerank and qwen3-vl-rerank. Guides the model to apply different sorting policies. Examples:
float (Optional)qwen3-vl-rerank only. Controls video frame extraction count. Smaller values = fewer frames. Range: 0-1 (default: 1.0). |
Replace |
Responserequest_idstringUnique request identifier for tracing and troubleshooting.output objectTask output.For
Properties results arraySorting results, ordered by relevance_score descending.
Properties document dictOriginal document object. Returned only when return_documents is true. Format: {"text": "Original document text"}.index intDocument index in the input documents array.relevance_score doubleSemantic relevance between document and query. Range: 0.0-1.0 (higher = more relevant).Scores are relative to the current request and cannot be compared across requests. objectToken usage statistics.
Properties total_tokens intTotal tokens consumed by the request.stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
|
Use the SDK
Example
Call the rerank model API.
SDK parameter names match the HTTP API, but the structure differs. HTTP uses nestedinputandparametersobjects; the SDK uses a flat structure.
qwen3-vl-rerank for multimodal reranking with an image query.
Sample output
The SDK wraps the HTTP response. For successful requests,
code and message are always empty strings.