A rerank model re-scores documents returned by initial retrieval, surfacing the most relevant results at the top.
Model overview
Model | Max documents | Max input tokens per item | Max input tokens per request | Supported languages | Scenarios |
|---|---|---|---|---|---|
qwen3.7-text-rerank | 500 | 30,000 | 120,000 (recommended) | 201 major languages and dialects, including Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, and Russian |
|
qwen3-vl-rerank | Text: 100 Image: 40 Video: 4 | 8,000 | 120,000 | 33 major languages, such as Chinese, English, Japanese, Korean, French, and German |
|
qwen3-rerank | 500 | 4,000 | Over 100 major languages, such as Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, and Russian |
| |
gte-rerank-v2 | 30,000 | Over 50 languages, such as Chinese, English, Japanese, Korean, Thai, Spanish, French, Portuguese, German, Indonesian, and Arabic |
- Max input tokens per item: Maximum tokens per query or document. If a query or document exceeds this limit, the API returns an HTTP 400 error and does not truncate the input.
- 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
Replace {WorkspaceId} with your actual workspace ID.
This section describes the DashScope HTTP API.qwen3-rerankandqwen3.7-text-rerankalso support the OpenAI-compatible API. See OpenAI-compatible API.
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.7-text-rerank, qwen3-rerank, gte-rerank-v2, qwen3-vl-rerank.input object (Required)Input content.Nest
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.Nest
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, qwen3-rerank.instruct string (Optional)Custom sorting instruction. Applies to qwen3.7-text-rerank, qwen3-rerank, and qwen3-vl-rerank. Guides the model to apply different sorting policies. Examples:
float (Optional)Only qwen3-vl-rerank supports this parameter. It controls the number of frames extracted per second of video. Smaller values extract fewer frames. Range: (0, 5]. Default: 1.0. |
|
Responserequest_idstringUnique request identifier for tracing and troubleshooting.output objectTask output.
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 prompt_tokens intReturned only by qwen3.7-text-rerank. The total number of tokens in the request input.total_tokens intThe total tokens consumed by the request, used for billing and audit.stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
|
OpenAI-compatible API
qwen3-rerank and qwen3.7-text-rerank can be called through the OpenAI-compatible API. gte-rerank-v2 and qwen3-vl-rerank are not supported and return a model_not_supported error.
Endpoint: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-api/v1/reranks
Differences from the DashScope HTTP API:
- The request body is flat.
query,documents,top_n,instruct, andreturn_documentsare top-level fields alongsidemodel, instead of being nested ininputandparameters. - The ranked results are in the
resultsarray of the response. Each item containsindex(the position of the document in the request) andrelevance_score. Whenreturn_documentsistrue, each item also containsdocument.text.
Sample request
Sample response
Use the SDK
Example
The following example shows how to call the document 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 model for multimodal reranking with an image as the query.
Sample output
resp.results (resp.results[i].index / .relevance_score / .document); failed requests throw a DashScopeError exception.