The text embedding model converts text data into numerical vectors for downstream tasks, such as semantic search, recommendation, clustering, and categorization.
Model overview
Singapore
Model | Embedding dimensions | Batch size | Max tokens per batch (Note) | Price (Million input tokens) | Supported languages | Free quota(Note) |
text-embedding-v4 Part of the Qwen3-Embedding series | 2,048, 1,536, 1,024 (default), 768, 512, 256, 128, 64 | 10 | 8,192 | $0.07 | Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and 100+ other major languages | 1 million tokens Valid for 90 days after you activate Model Studio. |
text-embedding-v3 | 1,024 (default), 768, 512 | Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and 50+ other major languages | 500,000 tokens Validity: 90 days after you activate Model Studio |
Beijing
Model | Embedding dimensions | Batch size | Max tokens per batch | Price (Million input tokens) | Supported languages |
text-embedding-v4 Part of the Qwen3-Embedding series | 2,048, 1,536, 1,024 (default), 768, 512, 256, 128, 64 | 10 | 8,192 | $0.072 | Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, Russian, and 100+ other major languages and multiple programming languages |
For model rate limits, see Rate limits.
Preparations
If you are familiar with the OpenAI ecosystem, you can use the OpenAI compatible API for a quick migration. The DashScope API provides more exclusive features. Choose the API that best suits your needs.
You must obtain an API key and set the API key as an environment variable. If you use an SDK to make calls, you must also install the DashScope SDK.
OpenAI compatible
base_url for SDK:
Singapore: https://dashscope-intl.aliyuncs.com/compatible-mode/v1
China (Beijing): https://dashscope.aliyuncs.com/compatible-mode/v1
endpoint for HTTP:
Singapore: POST https://dashscope-intl.aliyuncs.com/compatible-mode/v1/embeddings
China (Beijing): POST https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings
Request body | Input stringPythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings Input string listPythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings Input filePythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/compatible-mode/v1/embeddings Replace 'texts_to_embedding.txt' with your file name or path. |
model The model to call. Select a model name from the Model overview table. | |
input The input text to process. The value can be a string, an array of strings, or a file: When the input is a string, it can contain up to 8,192 tokens. When the input is a list of strings or a file, it can contain up to 10 items (lines), each with a maximum of 8,192 tokens. | |
dimensions The embedding dimensions. The value must be one of the following: 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 The format of the returned embedding. Only the |
Response object | Successful responseError response |
data The output data for the task. | |
model The model that was called. | |
object string The type of data returned by the call. The default value is list. | |
usage | |
id string The unique request ID. You can use this ID to trace and troubleshoot requests. |
DashScope
base_url for SDK:
Singapore: https://dashscope-intl.aliyuncs.com/api/v1
China (Beijing): https://dashscope.aliyuncs.com/api/v1
Endpoint for HTTP:
Singapore: POST https://dashscope-intl.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding
China (Beijing): POST https://dashscope.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding
Request body | Input stringPythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding Input string listPythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding Input filePythonJavacurlIf you use a model in the China (Beijing) region, use an API key for that region and replace the URL with: https://dashscope.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding Replace 'texts_to_embedding.txt' with your file name or path. |
model The model to call. Select a model name from the Model overview table. | |
input The input text to process. The value can be a string, an array of strings, or a file: A string input can contain up to 8,192 tokens. A list of strings or a file can contain up to 10 items (lines), and each item (line) can contain up to 8,192 tokens. | |
text_type Text vectors can be used for downstream tasks such as retrieval, clustering, and categorization. For asymmetric tasks such as retrieval, we recommend that you distinguish between a query and a document to achieve better results. For symmetric tasks such as clustering and categorization, you can use the default value | |
dimension The embedding dimensions. The value must be one of the following: 2048 (for text-embedding-v4 only), 1536 (for text-embedding-v4 only), 1024, 768, 512, 256, 128, or 64. The default value is 1024. | |
output_type Specifies whether to output a sparse vector representation. This parameter applies only to the text-embedding-v3 and text-embedding-v4 models. Valid values are dense, sparse, and dense&sparse. The default value is dense, which returns only a dense vector. | |
instruct A custom task description. This parameter takes effect only when you use the |
Response object | Successful responseError response |
status_code The status code. A value of 200 indicates a successful request. | |
request_id The unique request ID. You can use this ID to trace and troubleshoot requests. | |
code If the request fails, this parameter indicates the error code. If the request is successful, this parameter is empty. | |
message If the request fails, this parameter indicates the detailed error message. If the request is successful, this parameter is empty. | |
output The output data for the task. | |
usage |
Error codes
If a model call fails and an error message is returned, see Error messages.