Convert text to vectors for semantic search, recommendations, clustering, and classification.
Python SDK:
Java SDK:
Before you begin: get an API key, set it as an environment variable, and install the DashScope SDK if you use the SDK.
Set the SDK base URL
Python SDK:
Supported models
| Model | Dimensions | Max tokens | Batch size | Languages | Price (per 1M tokens) | Free quota |
|---|---|---|---|---|---|---|
| text-embedding-v4 | 2048, 1536, 1024 (default), 768, 512, 256, 128, 64 | 8,192 | 10 | 100+ | $0.07 | 1M tokens (90 days) |
| text-embedding-v3 | 1024 (default), 768, 512 | 8,192 | 10 | 50+ | $0.07 | 1M tokens (90 days) |
Input formats
- Single string: up to 8,192 tokens
- Array: up to 10 strings, each up to 8,192 tokens
- Text file: up to 10 lines, each line up to 8,192 tokens
DashScope-specific features
text_type: set toqueryordocumentfor asymmetric tasks like retrieval.output_type: return sparse vectors (dense&sparse) for hybrid search (v3/v4 only).instruct: add a task description to improve accuracy by ~1-5% (v4 only; English recommended).
Authorizations
string
header
required
DashScope API key. Obtain from the Qwen Cloud console.
Body
application/jsonResponse
200-application/json
integer
default"200"
The status code. A value of 200 indicates a successful request.
string
default"1ba94ac8-e058-99bc-9cc1-7fdb37940a46"
The unique request ID. Use this ID to trace and troubleshoot requests.
string
default""
If the request fails, this indicates the error code. Empty on success.
string
default""
If the request fails, this indicates the detailed error message. Empty on success.
object
The output data for the task.
object
default"{\"total_tokens\":27}"
Token usage statistics.