Qwen API: how to get a key and connect Qwen over an OpenAI-compatible API
The Qwen API speaks the OpenAI format: a key, a base_url and a model name. Alibaba Cloud Model Studio issues keys officially; below is that route, an OpenAI-compatible route through Twelver, a Python example and Qwen Code setup.
Short answer
Officially: an Alibaba Cloud account → Model Studio → API keys → Create API key, with a regional base_url that includes your workspace ID and /compatible-mode/v1. Through Twelver: series qwen-flash, qwen and qwen-max, with a key issued on this page with no signup and no card.
Qwen through Twelver
| Series | Model | $ per 1M |
|---|---|---|
| qwen-flash | Qwen3.8-Flash | 0.244 / 0.764 |
| auto / qwen | Qwen3.7-Plus | 0.65 / 2.6 |
| qwen-max | Qwen3.8-Max | 3.25 / 9.75 |
Right here
Base URL and key for Qwen
Your own values appear in the block and drop straight into the code below.
Press it and get your base_url and API key.
No sign-up, no card.
Free. Your key appears right here.
qwen.pyThe highlighted parts are stand-ins. The button above issues them in seconds, no sign-up.from openai import OpenAI
client = OpenAI(base_url="https://twelver.ru/api/ai/<your-config-id>/v1", api_key="sk-<your-key>")
reply = client.chat.completions.create(
model="qwen",
messages=[{"role": "user", "content": "Write a sorting function in Python"}],
)
print(reply.choices[0].message.content)Qwen Code with your key
~/.zshrcThe highlighted parts are stand-ins. The button above issues them in seconds, no sign-up.export OPENAI_BASE_URL="https://twelver.ru/api/ai/<your-config-id>/v1"
export OPENAI_API_KEY="sk-<your-key>"
export OPENAI_MODEL="qwen"Qwen Code switches to an OpenAI-compatible provider when all three variables are set; then run qwen and pick the provider with /auth.
Next: DeepSeek API, Cline, OpenCode, API for AI agents.
Work out what the requests cost
Pick a workload or type your own numbers — the calculator multiplies them by each series’ rates. A token is roughly 4 characters of English text or code.
qwen-flashQwen3.8-Flash$24.71 per monthautoQwen3.7-Plus$67.86 per monthqwen-maxQwen3.8-Max$328 per monthzaiGLM-5.3$231 per monthTwelver rates as of 4 November 2026; tokens are billed as actually used, caching and discounts not included. The arithmetic runs in your browser.
Frequently asked questions
How do I get a Qwen API key?
How do I connect Qwen Code to my own API?
Can I use Qwen without an Alibaba Cloud account?
Try it yourself
Everything in this guide runs inside Twelver
One chat for text, images, video, music and voice — no separate services or subscriptions.
Open Twelver chat