Model overview
Model name | Data type | Vector dimensions | Maximum lines per request | Maximum input tokens per line | Supported languages |
|---|---|---|---|---|---|
text-embedding-async-v2 | 32-bit float | 1,536 | 100,000 | 2,048 | Chinese, English, Spanish, French, Portuguese, Indonesian, Japanese, Korean, German, and Russian |
text-embedding-async-v1 | Chinese, English, Spanish, French, and Portuguese, Indonesian |
Model name | Price (per 1,000 input tokens) | Free quota (Note) | Throttling conditions (Throttling is triggered if any limit is exceeded) | |
|---|---|---|---|---|
RPS limit for task submission API | Number of concurrent processing tasks | |||
text-embedding-async-v2 | CNY 0.0007 | 20 million tokens Validity: 90 days after you activate Model Studio | 1 | A user can have a maximum of 50 tasks that are queued or running for the general text embedding asynchronous service. In addition, to prevent resource exhaustion from burst requests, a user can run a maximum of 3 tasks concurrently. Other tasks must wait in the queue. |
text-embedding-async-v1 | No free quota | |||
Prerequisites
You can call the general text embedding batch processing API using HTTP and the DashScope software development kit (SDK).
Before making a call, get an API key and export the API key as an environment variable. To make calls using the SDK, install the DashScope SDK.
HTTP calls
HTTP calls support only asynchronous mode and involve two steps:
- Create a task: Send a request to create a task. The request returns a task ID.
- Query the result by task ID: Use the task ID from the previous step to query the result generated by the model.
POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding
Replace {WorkspaceId} with your actual workspace ID.
Create a task
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Content-Type string (Required)The content type of the request. Must be application/json.X-DashScope-Async string (Required)Asynchronous processing configuration parameter. HTTP requests only support asynchronous processing, and this parameter must be set toenable.Request bodymodelstring(Required)The name of the model to call. You can select text-embedding-async-v1 or text-embedding-async-v2.input object (Required)The input for batch vectorization.
Property url string (Required)The HTTP URL of the file for batch vectorization. Each line contains one entry to be embedded.Text limits:
object (Optional)Parameters for vectorization.
Property text_type string (Optional)Parameter values:
document. |
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes. |
Please save the task_id, which is used to query the task status and results. |
Query the result by task ID
GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.Path parameterstask_idstring (Required)The ID of the task. |
Please replace 86ecf553-d340-4e21-xxxxxxxxx with the actual task_id.If you use a model in the Singapore region, replace base_url with https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/86ecf553-d340-4e21-xxxxxxxxx, where {WorkspaceId} must be replaced with the actual workspace ID. |
Response parametersoutputobjectTask output information.
Property task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.url stringThe URL of the output file generated by the model.codestringError code. Returned only for failed requests. See Error codes.messagestringDetailed error message. Returned only for failed requests. See Error codes.objectStatistics for the output information. Only successful results are counted.
Property total_tokens integerThe number of tokens in the input content for the request. This number is calculated based on the tokens that are parsed by the model's tokenizer from the input text file.stringUnique request identifier for tracing and troubleshooting. |
Task data, such as the task status and result URL, is retained for only 24 hours and then automatically deleted. You must save the generated output file promptly. |
Dashscope
To avoid errors, make sure that you have installed the latest version of the DashScope SDK. For more information, see Install the SDK.
The DashScope SDK is available in Python and Java.
The parameter names for the SDK and HTTP API are mostly the same. The parameter structure depends on the SDK encapsulation for each language. For parameter descriptions, see Wanxiang text-to-image V2.
Because the model requires a long processing time, the underlying service is provided asynchronously. The SDK is encapsulated to support both synchronous and asynchronous calls.
Request bodymodelstring(Required)The name of the model to call. You can select text-embedding-async-v1 or text-embedding-async-v2.url string (Required)The HTTP URL of the file for batch vectorization. Each line contains one entry to be vectorized.Text limits:
string(Optional)After text is converted to vectors, you can use them for downstream tasks, such as retrieval, clustering, and classification. For asymmetric tasks such as retrieval, distinguish between query text (query) and document text (document) for better results. For symmetric tasks such as clustering and classification, you can use the default value document. |
Python |
Response parametersIn DashScope Python SDK 2.0,request_id stringUnique request identifier for tracing and troubleshooting.task_idstringA unique identifier for the task. You can use it to trace task details and troubleshoot issues.statusstringThe task status.
stringThe URL that contains the embedding results. This parameter is empty if the task fails. You can read it via job.result_url.codestringIf the task fails, this parameter indicates the reason for the failure (corresponding to e.code of the exception). This parameter is not returned for successful executions. For more information, see Error messages.messagestringIf the task fails, this parameter provides detailed information about the failure (corresponding to e.message of the exception). This parameter is not returned for successful executions.Failed callsWhen a request fails or a task execution fails, the SDK raises DashScopeError; you can obtain the failure details via e.status_code (HTTP status code), e.code (error code), e.message (error message), and e.request_id (unique request ID). For more information, see Error messages.usageobjectProperty
Details total_tokens integerThe number of tokens in the input content for the request. This number is calculated based on the tokens that are parsed by the model's tokenizer from the input string. |
|
FAQ
Input file limits
- The input file must be a text file encoded in UTF-8. Each line contains a string for which a text vector is computed. The system processes the input line by line and includes the corresponding line number and the generated embedding result in the output file.
- A single file cannot exceed 200 MB.
- The number of text lines in a single request cannot exceed 100,000.
- The content of each line cannot exceed 2,048 tokens.
- Blank lines, which are lines that do not contain any characters, are automatically skipped by the system, and their text vectors are not computed. However, the line numbers of these blank lines are retained in the output file to facilitate result mapping.
Output file format
- When the task is successfully completed, the submitted input data is converted into vector results and stored in an output file. To save storage space and facilitate downloading, the output file is compressed into the
.gzformat. After you download the file, you can decompress it to obtain the text output file. - Task data, such as the task status and result URL, is retained for only 24 hours and then automatically deleted. You must save the output file that contains the task results promptly.
- The output file that is generated by the model after vectorization is a JSONL file. Each line is a complete JSON structure that contains the vectorized output for a specific line from the input file.