For non-real-time scenarios like data annotation and content generation, the Batch Chat API offers a low-cost, high-concurrency alternative using the same synchronous call method. Limited-time 50% discount available.
This API supports only single-request submissions. To submit multiple requests at once, package them in a file. See OpenAI-compatible - Batch (file input).
How it works
- Submit request: The client sends a request and establishes a connection.
- Queue and wait: The request enters a queue while the client maintains the connection.
-
Return result: The server returns the complete result over the established connection after processing.
The connection disconnects with a timeout error if the maximum wait time is exceeded.
Availability
- China (Beijing)
- Text generation models: qwen3.8-max, qwen3.7-max, qwen3.7-plus, qwen3.6-plus, qwen3.7-flash, qwen3.6-flash, qwen3.5-plus, qwen3.5-flash, qwen3-max, qwen-plus, qwen-flash, deepseek-v3.2
- Image and video understanding models: qwen3.8-max, qwen3.7-plus, qwen3.6-plus, qwen3.7-flash, qwen3.6-flash, qwen3.5-plus, qwen3.5-flash, qwen3.5-omni-plus, qwen3-vl-plus, qwen3-vl-flash
Usage
Prerequisites
-
Activate Alibaba Cloud Model Studio and get an API key.
Configure the API key as an environment variable to reduce leak risk.
- To use OpenAI SDK, install it:
Step 1: Configure the API endpoint
Switch from real-time to batch inference by modifying the API endpoint (base_url) based on your call method:
SDK: Set base_url to https://batch.dashscope.aliyuncs.com/compatible-mode/v1
HTTP: POST https://batch.dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
Step 2: Make a call
The following examples show how to call the Batch Chat API. Default timeout is 3600 seconds (1 hour); no extra configuration is needed in most cases.
Custom timeout range: 60–3600 seconds.
- Python
- Java
- Node.js
- Go
- C# (HTTP)
- PHP (HTTP)
- curl
Request exampleResponse example
Limitations
- Wait time: Maximum 3600 seconds (1 hour) for synchronous waiting. Set custom timeout: 60–3600 seconds.
- Concurrency limits:Maximum 10,000 pending requests per model per account. Exceeding requests rejected with error code. New requests accepted only after pending requests complete.
-
Call rate: Maximum 1000 QPS per account, or 10,000 calls per 10 seconds.
Theoretical maximum only. Actual availability depends on system load. Implement retry logic.
Billing
- Unit price: Billing based on input/output tokens in successful requests. List price matches real-time call price. Limited-time 50% discount available on official website. See Model list.
- Billing scope: Only successful requests billed. Failed requests (system errors or timeouts) not billed.
- Batch inference is a separate billing item. It supports AI general-purpose savings plan, but not discounts, such as subscription (other savings plans) or free quotas for new users. It also does not support features such as context cache.
- Some models, such as qwen3.5-plus and qwen3.5-flash, have thinking mode enabled by default. This mode generates additional thinking tokens, which are billed at the output token price and increase costs. To control costs, set the
enable_thinkingparameter based on task complexity. For more information, see Deep thinking.
Error codes
If the model call fails and returns an error message, see Error codes for resolution.
FAQ
- Is there a difference in request time between Batch Chat and the real-time API? Yes. Requests are queued for scheduling, so end-to-end time is typically longer than real-time API. Maximum wait: 1 hour. Connection disconnects with error if timeout exceeded.
- How do I choose between Batch Chat and Batch File? Choose Batch Chat for many independent dialogue requests with high concurrency via synchronous calls. Choose Batch File for processing a single large file with many requests via asynchronous retrieval.
- Does Batch Chat guarantee that all requests will be completed? No. Completion depends on shared resource allocation. Requests may queue if resources busy. Connection times out if not executed within maximum wait time. Timed-out requests are not billed; retry later.
References
- Complete parameter list for real-time model calls: OpenAI compatible - Chat.
- Batch processing via file submission with asynchronous results: OpenAI-compatible - Batch (file input).