
Qwen 2.5 API: Access, Rate Limits & SDKs 2026
Qwen runs on Alibaba Cloud Model Studio, reachable through OpenAI, Anthropic and native DashScope interfaces. Base URLs are region-specific.
Qwen 2.5 API verdict
Qwen runs on Alibaba Cloud Model Studio, authenticated with a single bearer DASHSCOPE_API_KEY and a region-specific base URL.
Regions span Singapore, Beijing, Tokyo, Frankfurt and Hong Kong, and several require a workspace ID in the URL. Its differentiator is breadth of compatibility.
Qwen's API is the most compatibility-flexible of the leading models. Whatever your existing code looks like, whether OpenAI, Anthropic, or a native SDK, you can keep it and point at Model Studio by swapping the base URL and key. Build on the OpenAI-compatible Chat Completion for the simplest migration, or the OpenAI-compatible Responses surface when you want built-in web search, a code interpreter and server-managed history without wiring them yourself. Plan around the operational edges: choose the correct regional base URL, include the workspace ID where required, and grant model authorization for any sub-workspace keys. Budget on tiered pricing, with qwen3.7-max at the top and qwen-plus and qwen-flash cheaper, plus a 90% cache-hit discount. Remember the model is text-only and weak at autonomous tool use.
- The base URL is region-specific, across Beijing, Singapore, Tokyo, Frankfurt and Hong Kong, so pick the right region or calls fail.
- Several regions require a workspace ID embedded in the base URL, found on the Workspace Management page.
- Sub-workspace API keys cannot access default-workspace models and return Model.AccessDenied until the root admin grants model authorization.
- It is a paid API on Alibaba Cloud, so store the key in DASHSCOPE_API_KEY rather than hardcoding it.
- Auth
- Bearer DASHSCOPE_API_KEY
- Surfaces
- OpenAI + Anthropic + DashScope
- Responses tools
- Web search + code interpreter
- Regions
- 5 (workspace ID some)
- Tiers
- max / plus / flash
Build with the Qwen 2.5 API
from openai import OpenAI
client = OpenAI(
api_key="<DASHSCOPE_API_KEY>",
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.7-max",
messages=[{"role": "user", "content": "Who are you?"}],
)
print(completion.choices[0].message.content){
"choices": [{
"message": { "role": "assistant",
"content": "I am Qwen, a large language model by Alibaba Cloud." },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 11, "completion_tokens": 14 }
}- Cost levers: prompt caching (cache hit $0.25/1M, 90% off); lower tiers qwen-plus / qwen-flash; OpenAI-compatible Responses built-in tools (no extra wiring).
- Handle: Model.AccessDenied (sub-workspace key needs model authorization).
Real Qwen 2.5 code from the official docs. The raw cURL hello-world is the code block above; full limits and endpoints are in the tables on this page.
Your first Qwen 2.5 API request
curl https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [{"role": "user", "content": "Who are you?"}]
}'How to authenticate with the Qwen 2.5 API
| Aspect | Detail | Notes |
|---|---|---|
| Auth | Bearer DASHSCOPE_API_KEY | Create a key on the Model Studio API Key page |
| Base URL | Region-specific .../compatible-mode/v1 | Singapore, Beijing, Tokyo, Frankfurt, Hong Kong; some regions need WorkspaceId in the URL |
| Drop-in | OpenAI Python / JS SDK or DashScope SDK | OpenAI-compatible chat completions |
| Models | qwen3.7-max (flagship), qwen-plus, qwen-flash | See the Model list for all Qwen models |
| Activation | Activate Model Studio + accept Terms | Per Alibaba Cloud account |
| Workspace scope | Sub-workspace keys need model authorization | Model.AccessDenied otherwise |
| Four interfaces | OpenAI Chat, OpenAI Responses, Anthropic Messages, DashScope | Pick the surface that matches your existing code |
Core interfaces and features
| Capability | How | Purpose |
|---|---|---|
| OpenAI Chat Completion | POST /compatible-mode/v1/chat/completions | Drop-in OpenAI chat; lowest-friction migration |
| OpenAI Responses | Responses interface | Built-in web search, code interpreter, web extractor; auto history |
| Anthropic Messages | Anthropic-compatible Messages | Thinking and tool calling for Anthropic-shaped code |
| DashScope native | DashScope SDK | Most complete set of features and parameters |
| Streaming | stream=True | Stream tokens as generated |
| Structured output | JSON schema response format | Schema-conforming JSON responses |
| Function calling | tools[] definitions | Call developer-defined tools during generation |
| Thinking / reasoning | Reasoning mode (Anthropic Messages: thinking) | Extended chain-of-thought before the answer |
Regions, workspaces and errors
| Limit | Detail | Notes |
|---|---|---|
| Regions | Beijing, Singapore, Tokyo, Frankfurt, Hong Kong | Base URL varies by region |
| Workspace ID | Required in the Base URL for several regions | Find it on Workspace Management |
| Sub-workspace auth | Model.AccessDenied without model authorization | Root admin grants per sub-workspace |
| Error reference | Per-code error reference page | Maps codes to causes and fixes |
| Key handling | Store key in DASHSCOPE_API_KEY env var | Avoid hardcoding credentials |
| Model selection | qwen3.7-max / qwen-plus / qwen-flash tiers | Pick tier by cost and capability |
| Interfaces share models | Same models across the four interfaces | Choose by existing code shape |
SDKs, surfaces and developer fit
| Aspect | Detail | Notes |
|---|---|---|
| SDKs | OpenAI SDK, Anthropic SDK, DashScope SDK | Drop-in via base URL + key |
| Built-in tools | Web search, code interpreter, web extractor | On the OpenAI-compatible Responses surface |
| Auto history | Conversation history managed server-side | On the Responses interface |
| Thinking + tools | Anthropic-compatible Messages supports both | For Anthropic-shaped agents |
| Advanced features | Streaming, structured output, function calling | See the text-generation overview |
| Playground | Browser dialog box like Qwen Chat | Test before coding |
| API pricing (qwen3.7-max) | $2.50/1M in, $7.50/1M out, cache hit $0.25/1M | Independent cross-reference |
Qwen 2.5 API FAQ
How do I authenticate with the Qwen API?
Activate Alibaba Cloud Model Studio, create an API key on the API Key page, and store it in the DASHSCOPE_API_KEY environment variable. Send it as a bearer token and point your client at the region-specific base URL ending in /compatible-mode/v1, such as the Singapore endpoint. Several regions also require your workspace ID embedded in the base URL.
Can I use the OpenAI or Anthropic SDK with Qwen?
Yes, and that is Qwen's main API advantage. The same models are exposed through four interfaces. There is an OpenAI-compatible Chat Completion, a drop-in for the OpenAI SDK, and an OpenAI-compatible Responses surface with built-in web search, a code interpreter and a web extractor. There is an Anthropic-compatible Messages API with thinking and tool calling, plus the native DashScope SDK. Swap the base URL and key and keep your existing client.
What can the Qwen API do beyond basic chat?
It supports streaming output, structured, schema-conforming output and function calling across the interfaces. The OpenAI-compatible Responses surface adds built-in agentic tools, a web search, a code interpreter and a web extractor, and manages conversation history automatically. The Anthropic-compatible Messages API exposes thinking and tool calling for Anthropic-shaped agents.
What are the operational limits of the Qwen API?
The constraints are region and workspace rather than a single endpoint. The base URL is region-specific, across Beijing, Singapore, Tokyo, Frankfurt and Hong Kong, and several regions require a workspace ID in the URL. Sub-workspace API keys cannot reach default-workspace models, returning Model.AccessDenied until the root administrator grants model authorization. Errors map to a published error-code reference.
Which Qwen model should I call and how is it priced?
qwen3.7-max is the flagship, at $2.50 per 1M input and $7.50 per 1M output tokens, with cache hits 90% cheaper at $0.25 per 1M. For lower cost, Model Studio also offers cheaper tiers such as qwen-plus and qwen-flash; see the Model list. Pick the tier by the cost-versus-capability trade-off your workload needs.
Sources & verification
| Source | What was checked | Last checked |
|---|---|---|
| GitHub Official | Official product page | July 10, 2026 |
| Alibabacloud Model Studio First Api Call To Qwen | Model Studio First API Call To Qwen | July 10, 2026 |
| Alibabacloud Model Studio Qwen Api Reference | Model Studio Qwen API Reference | July 10, 2026 |
| Artificial Analysis | Independent reference | July 10, 2026 |
Every fact on this Qwen 2.5 page is tied to a named source and a verification date. Freshness-sensitive figures trace to the sources above; verify against the vendor before relying on them.
Explore Qwen 2.5
Every page on Qwen 2.5 in one place, you are on api.
