// Models · API key guide
Qwen API key: how to get one
Qwen models are sold through Alibaba Cloud Model Studio (Bailian); the key you create there is the DashScope key (DASHSCOPE_API_KEY).
5 stepsofficial docs onlychecked 2026-10-26
01How to get a Qwen (Tongyi Qianwen) API key
- Log in to Alibaba Cloud and open the Model Studio (Bailian) console; activate the service if prompted (real-name verification may be requested – follow the console).
- Choose the region first (e.g. China (Beijing)). Keys are tied to a region and do not work across regions.
- Open “API Key” → “Create API Key”, pick the owning account and workspace, and set permissions (all, or limited by model / IP).
- Copy the key into the environment variable DASHSCOPE_API_KEY.
- Call qwen3.8-max (or another Qwen model) through the OpenAI-compatible endpoint below.
Official key page: https://bailian.console.aliyun.com/?tab=model#/api-key – console labels may change; follow what the official page shows.
02Real-name, phone and credit card requirements
| Real-name / ID verification | Not needed to receive or use the free quota; needed to continue with pay-as-you-go after it runs out. Unverified accounts have “stop when free quota runs out” forced on. |
|---|---|
| Phone number | An Alibaba Cloud account is required; account sign-up rules are on Alibaba Cloud’s site. |
| Credit card / payment | Not needed for the free quota. Paid usage is billed to your Alibaba Cloud account. |
03Base URL and a minimal call
https://dashscope.aliyuncs.com/compatible-mode/v1DASHSCOPE_API_KEY · Example model:qwen3.8-maxcurl
curl https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "你好"}]
}' Python
# pip install openai
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DASHSCOPE_API_KEY"], base_url="https://dashscope.aliyuncs.com/compatible-mode/v1")
resp = client.chat.completions.create(
model="qwen3.8-max",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content) 04Free quota
All free AI APIs →New-user free quota: granted automatically on first activation, usually about 1M tokens per model, valid 90 days, China (Beijing) region only, real-time inference only, shared by the main account and its RAM users.
05Qwen (Tongyi Qianwen) API prices
All model prices →| Model | Input / 1M tokens | Output / 1M tokens | Source |
|---|---|---|---|
Qwen3.7-Flashqwen3.7-flash | ¥0.2 | ¥0.8 | official · 2026-10-10 |
Qwen-Turboqwen-turbo | ¥0.3 | ¥0.6 | official · 2026-10-10 |
Qwen-Flashqwen-flash | ¥0.15 | ¥1.5 | official · 2026-10-10 |
Qwen3-VL-Flashqwen3-vl-flash | ¥0.15 | ¥1.5 | official · 2026-10-10 |
Qwen3.5-Flashqwen3.5-flash | ¥0.2 | ¥2 | official · 2026-10-10 |
Qwen-Longqwen-long | ¥0.5 | ¥2 | official · 2026-10-10 |
Qwen-Plusqwen-plus | ¥0.8 | ¥2 | official · 2026-10-10 |
Qwen3.5-35B-A3Bqwen3.5-35b-a3b | ¥0.4 | ¥3.2 | official · 2026-10-10 |
Standard (non-batch) list prices from our price database; cheapest first, max 8 rows. Prices change – the official page wins.
06Keep your API key safe
- Up to 50 keys per account per region. For browsers or apps, use a temporary key (max 1,800 s) issued by your server, not a long-lived key.
- Turn on “stop when free quota runs out” if you only want to try the free quota.
- Keep the key in an environment variable or a secrets manager – never hard-code it, never commit it to Git, never paste it into a screenshot, chat or issue.
- Never put a long-lived key in front-end, mobile or desktop client code – anyone can extract it. Call the API from your own server.
- One key per project or environment, so a leak can be revoked without breaking everything else.
- If a key leaks, delete it in the console immediately and create a new one, then check usage and billing.
- Do not buy keys from resellers or “API relays” and do not paste your key into websites you do not trust.
07FAQ
FAQ
Where do I get a Qwen API key?
In the Alibaba Cloud Model Studio (Bailian) console → API Key → Create API Key. There is no separate “Qwen” key – the Bailian / DashScope key is it.
Is the Qwen API free?
New users get a free quota (about 1M tokens per model, 90 days, Beijing region). After that it is pay-as-you-go.
Can I use the OpenAI SDK with Qwen?
Yes – set base_url to the compatible-mode endpoint (https://dashscope.aliyuncs.com/compatible-mode/v1 for Beijing) and use your DashScope key.
08Official sources
- 阿里云百炼 · 获取 API Key help.aliyun.com
- 阿里云百炼 · 首次调用千问 API help.aliyun.com
- 阿里云百炼 · 新人免费额度 help.aliyun.com
- 阿里云百炼 · OpenAI 兼容 help.aliyun.com
All facts checked against these pages on 2026-10-26. If anything differs, the official page wins.