Qwen API: how to get a key and connect Qwen over an OpenAI-compatible APIAn API for AI coding agents: one key, any OpenAI-compatible tool

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

SeriesModel$ per 1M
qwen-flashQwen3.8-Flash0.244 / 0.764
auto / qwenQwen3.7-Plus0.65 / 2.6
qwen-maxQwen3.8-Max3.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.

Template — this will not work as isqwen.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

Template — this will not work as is~/.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 month
request: $0.00821,000 requests: $8.24
autoQwen3.7-Plus$67.86 per month
request: $0.0231,000 requests: $22.62
qwen-maxQwen3.8-Max$328 per month
request: $0.1091,000 requests: $109
zaiGLM-5.3$231 per month
request: $0.0771,000 requests: $76.98

Twelver 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?
In Alibaba Cloud Model Studio: create an account, accept the terms, then API keys → Create API key. The base_url is your region’s address with the workspace ID and /compatible-mode/v1.
How do I connect Qwen Code to my own API?
Set OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL, run qwen and choose the provider with /auth.
Can I use Qwen without an Alibaba Cloud account?
Yes, through an OpenAI-compatible provider. Twelver serves Qwen as the qwen-flash, qwen and qwen-max series, with a key issued without signup or a card.

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
Rate your experience