Skip to main content

Synchronous API

The general-purpose text embedding model converts text data into numerical vectors for downstream tasks like semantic search, recommendation, clustering, and classification.

Model overview

ModelEmbedding dimensionsMax rowsMaxtokensper linePrice (per 1K input tokens)Supported languagesFree quota(Note)
qwen3.7-text-embedding2,560, 2,048, 1,536, 1,024 (default), 768, 512, 25620128,000CNY 0.0005Batch call: CNY 0.00025Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and over 200 other major languages and dialects1 million tokens eachValidity: 90 days after you activate Model Studio
qwen3.7-text-embedding-flash1,024 (default), 768, 512, 25620128,000CNY 0.000125Batch call: CNY 0.000063Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and over 200 other major languages and dialects
text-embedding-v4
Part of the Qwen3-Embedding series
2,048, 1,536, 1,024 (default), 768, 512, 256, 128, 64108,192CNY 0.0005Batch call: CNY 0.00025Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and over 100 other major languages, plus multiple programming languages
text-embedding-v31,024 (default), 768, 512, 256, 128, or 64Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and over 50 other major languages
text-embedding-v21,536252,048CNY 0.0007Batch call: CNY 0.00035Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian500,000 tokens eachValidity: 90 days after you activate Model Studio
text-embedding-v1Chinese, English, Spanish, French, Portuguese, Indonesian
For model rate limits, see Rate limiting.

Prerequisites

Users familiar with the OpenAI ecosystem can use the OpenAI-compatible API for a quick migration. The DashScope API provides more unique features. Obtain an API key and export the API key as an environment variable. If you use an SDK to make calls, install the DashScope SDK.

OpenAI compatibility

  • Public cloud
Thebase_urlto configure for SDK calls:https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1Theendpointto configure for HTTP calls:POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/embeddingsReplace {WorkspaceId} with your actual workspace ID.

Request body

modelstringrequiredThe name of the model to call. See the Model overview table for model names.inputarray<string> or string or filerequiredThe input text to process. The input can be a string, an array of strings, or a file. Limits on text length and batch size vary by model version:
  • qwen3.7-text-embedding model:
    • String input: Up to 128,000 tokens.
    • String list or file input: Up to 20 items (lines), with each item (line) up to 128,000 tokens.
  • text-embedding-v3 / v4 models:
    • String input: Maximum length of 8,192 tokens.
    • String list or file input: A maximum of 10 items (lines), where each item (line) can be up to 8,192 tokens.
  • text-embedding-v1 / v2 models:
    • String input: Maximum length of 2,048 tokens.
    • String list or file input: A maximum of 25 items (lines), where each item (line) can be up to 2,048 tokens.
dimensions integer optionalThe dimension of the output embedding vectors. Must be one of the following values: 2560 (for qwen3.7-text-embedding only),2048 (for text-embedding-v4 only), 1536 (for text-embedding-v4 only), 1024, 768, 512, 256, 128, or 64. The default value is 1024.encoding_format string optionalThe returned embedding format. Currently, only float is supported.
  • Input string
  • Input string list
  • Input file
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),  # If the environment variable is not set, replace the placeholder with your API key.
    # China (Beijing) region URL. Replace {WorkspaceId} with your actual workspace ID. URLs differ by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
)

completion = client.embeddings.create(
    model="qwen3.7-text-embedding",
    input='The quality of the clothes is excellent and they are beautiful. It was well worth the wait. I love them and will buy from here again.',
    dimensions=1024, # Sets the embedding dimensions (only for qwen3.7-text-embedding, text-embedding-v3, and text-embedding-v4).
    encoding_format="float"
)

print(completion.model_dump_json())
The SDK Expert interactive assistant can accomplish the same development and troubleshooting in natural language. See DashScope SDK Expert.

Response object

dataarrayA list of the resulting embedding objects.

Property

embeddinglistThe embedding vector, returned as an array of floating-point numbers.indexintegerThe index of the corresponding input text in the input array.objectstringThe object type. The value is always embedding.
modelstringThe name of the model used for this call.objectstringThe object type. The value is always list.usageobjectToken usage. qwen3.7-text-embedding-flash returns prompt_tokens and total_tokens; other existing text embedding models return only total_tokens.

Property

prompt_tokensintegerReturned only by qwen3.7-text-embedding-flash. The total number of tokens in the request input.total_tokens integerThe total number of tokens in the request, used for billing and audit. This count is determined by how the model's tokenizer parses the input string.
idstringA unique request identifier, used for tracing and troubleshooting.
{
  "data": [
    {
      "embedding": [
        -0.0695386752486229, 0.030681096017360687, ...
      ],
      "index": 0,
      "object": "embedding"
    },
    ...
    {
      "embedding": [
        -0.06348952651023865, 0.060446035116910934, ...
      ],
      "index": 5,
      "object": "embedding"
    }
  ],
  "model": "qwen3.7-text-embedding",
  "object": "list",
  "usage": {
    "total_tokens": 184
  },
  "id": "73591b79-d194-9bca-8bb5-xxxxxxxxxxxx"
}

DashScope

  • Public cloud
base_urlfor SDK calls: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1Endpoint for HTTP calls: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embeddingReplace {WorkspaceId} with your actual workspace ID.

Request body

modelstringrequiredThe model to use. For a list of available models, see the Model overview table.inputstringorarray<string>requiredThe text to process. The input can be a string, an array of strings, or a file. The supported text length and batch size vary by model version.
  • qwen3.7-text-embedding and qwen3.7-text-embedding-flash models:
    • String input: Up to 128,000 tokens.
    • String list or file input: Up to 20 items (lines), with each item (line) up to 128,000 tokens.
  • text-embedding-v3 / v4 models:
    • String input: Up to 8,192 tokens.
    • String list or file input: Up to 10 items (lines), with each item up to 8,192 tokens.
  • text-embedding-v1 / v2 models:
    • String input: Up to 2,048 tokens.
    • String list or file input: Up to 25 items (lines), with each item up to 2,048 tokens.
text_type stringoptional
When making an HTTP call, place text_typein the parameters object.
Text converted to embeddings can be applied to downstream tasks such as retrieval, clustering, and classification. For asymmetric tasks such as retrieval, it is recommended to differentiate between query text (query) and document text (document) to achieve better retrieval performance. For symmetric tasks such as indexing, clustering, and classification, you can simply use the system default value of document.dimension integer optional
When making an HTTP call, place dimensionin the parameters object.
Specifies the embedding dimension for the output vector. Valid values are 2560 (for qwen3.7-text-embedding only),2048 (for text-embedding-v4 only), 1536 (for text-embedding-v4 only), 1024, 768, 512, 256, 128, or 64. Defaults to 1024.output_type string optional
When making an HTTP call, place output_typein the parameters object.
Specifies the output vector type. This parameter applies only to the qwen3.7-text-embedding,``text-embedding-v3, and text-embedding-v4 models. Valid values are dense, sparse, and dense&sparse. Defaults to dense, which returns only the dense vector representation. Sparse vector outputs (sparse and dense&sparse) are supported only through the DashScope API.instruct string optionalProvides custom instructions to guide the model in understanding the query intent. English instructions are recommended, as they typically improve performance by 1% to 5%.
  • Input string
  • Input string list
  • Input file
Python
import dashscope
from http import HTTPStatus
# China (Beijing) region configuration. Replace {WorkspaceId} with your actual workspace ID. Configurations differ by region.
dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

resp = dashscope.TextEmbedding.call(
    model="qwen3.7-text-embedding",
    input='The quality of the clothes is excellent and they are beautiful. It was well worth the wait. I love them and will buy from here again.',
    dimension=1024,  # Specifies the output embedding dimension. This parameter is available only for qwen3.7-text-embedding, text-embedding-v3, and text-embedding-v4 models.
    output_type="dense&sparse"
)

print(resp) if resp.status_code == HTTPStatus.OK else print(resp)

Response object

status_code stringThe HTTP status code. A value of 200 indicates success.request_id stringA unique identifier for the request. Use this ID to trace and troubleshoot the request.code stringThe error code returned if the request fails. This field is empty for successful requests.message stringA detailed error message if the request fails. This field is empty for successful requests.outputobjectThe result of the task.

Properties

embeddingsarrayThe model's output for the request. This is an array of objects, with each object corresponding to an input text.
sparse_embedding arrayThe sparse vector representation of the corresponding string. This applies only to text-embedding-v3 and text-embedding-v4.
index integerThe index of the token in the vocabulary.value floatIndicates the weight or importance score of the Token. The higher the value, the greater the importance or relevance of the Token in the current text context.token stringThe text of the token.
embedding arrayThe dense vector representation for the corresponding string.text_index integerThe index of the corresponding text in the input array.
usageobjectToken usage. qwen3.7-text-embedding-flash returns prompt_tokens and total_tokens; other existing text embedding models return only total_tokens.

Properties

prompt_tokens integerReturned only by qwen3.7-text-embedding-flash. The total number of tokens in the request input.total_tokens integerThe total number of tokens in the request, used for billing and audit. This count is determined by how the model's tokenizer parses the input string.
{   "status_code": 200,
    "request_id": "1ba94ac8-e058-99bc-9cc1-7fdb37940a46",
    "code": "",
    "message": "",
    "output":{
        "embeddings": [
          {
             "sparse_embedding":[
               {"index":7149,"value":0.829,"token":"swift"},
               .....
               {"index":111290,"value":0.9004,"token":"mournfully"}],
             "embedding": [-0.006929283495992422,-0.005336422007530928, ...],
             "text_index": 0
          },
          {
             "sparse_embedding":[
               {"index":246351,"value":1.0483,"token":"islet"},
               .....
               {"index":2490,"value":0.8579,"token":"back"}],
             "embedding": [-0.006929283495992422,-0.005336422007530928, ...],
             "text_index": 1
          },
          {
             "sparse_embedding":[
               {"index":3759,"value":0.7065,"token":"Boundless"},
               .....
               {"index":1130,"value":0.815,"token":"leaves"}],
             "embedding": [-0.006929283495992422,-0.005336422007530928, ...],
             "text_index": 2
          },
          {
             "sparse_embedding":[
               {"index":562,"value":0.6752,"token":"endless"},
               .....
               {"index":1589,"value":0.7097,"token":"in"}],
             "embedding": [-0.001945948973298072,-0.005336422007530928, ...],
             "text_index": 3
          }
        ]
    },
    "usage":{
        "total_tokens":27
    }
}

Error codes

If a model call fails, see Error Messages.
Text Generation
Image Generation
Video Generation
World models
3D Model Generation
Audio
  • Audio generation
Realtime API
Text Embedding
Decision Model
TokenPlan
Model Production
Synchronous API - 阿里云百炼