Qwen Code: installing, configuring your API and running Qwen3.8-Max / Qwen3.7-PlusAn API for AI coding agents: one key, any OpenAI-compatible tool

Qwen Code: installing, configuring your API and running Qwen3.8-Max / Qwen3.7-Plus

The short version: Qwen Code is the open-source terminal coding agent from the Qwen team. It connects to any OpenAI-compatible API via three environment variables — so you can run it on Twelver’s Qwen3.7-Plus and Qwen3.8-Max series in two minutes, without setting up an Alibaba Cloud Model Studio workspace.

$0.65input per 1M tokens on Qwen3.7-Plusqwen / auto series — daily agent default
$3.25input per 1M tokens on Qwen3.8-Maxqwen-max series for tough problems
3 env varsto wire your own APIOPENAI_BASE_URL, OPENAI_API_KEY, OPENAI_MODEL

What Qwen Code is and how it relates to Qwen models

Qwen Code is the CLI agent (the qwen binary) that reads your repository tree, edits files, runs shell commands and executes tests right in the terminal. Behind it sits the model you point it at — in Twelver’s API, that is Qwen3.7-Plus (qwen) for everyday speed or Qwen3.8-Max (qwen-max) for complex architecture and large contexts.

Because Qwen Code speaks the standard OpenAI Chat Completions format whenever OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL are set, you can plug in your own endpoint without vendor lock-in.

Step 1. Install Qwen Code CLI

Requires Node.js 20 or newer:

npm install -g @qwen-code/qwen-code

Check that the binary is on your PATH:

qwen --version

Step 2. Get your Base URL and API key

You need a Base URL of the form https://twelver.app/api/ai/<config-id>/v1 and an sk-… key. The widget below issues both on starter tokens — no signup and no card.

Right here on the page

Base URL and key for Qwen Code

Click once to create your config-id and key — both fill into the environment commands below automatically. You can also send a test request right here.

Press it and get your base_url and API key.

No sign-up, no card.

Free. Your key appears right here.

Step 3. Export all three environment variables

Add these lines to your shell profile (~/.zshrc or ~/.bashrc) or a local project .env file (keep .env in .gitignore):

Template — this will not work as is~/.zshrc or ~/.bashrcThe 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"

To run on flagship Qwen3.8-Max, change the last line to export OPENAI_MODEL="qwen-max" — the Base URL and key stay identical.

All three variables must be set

Qwen Code switches to an OpenAI-compatible provider only when OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL are all present together. If one is missing, the CLI falls back to browser OAuth. Also make sure OPENAI_BASE_URL ends in /v1 with no trailing slash.

Step 4. Launch Qwen Code and select the provider

source ~/.zshrc
cd your-project
qwen

On first launch (or any time inside a session), run /auth and choose the OpenAI-compatible option. To override the model for a single session without editing your profile:

OPENAI_MODEL="qwen-max" qwen

Choosing a Qwen series in Twelver API

SeriesModelIn / out, $ per 1MBest for
qwen-flashQwen3.8-Flash0.244 / 0.764Fast housekeeping calls, drafts and quick file checks
auto / qwenQwen3.7-Plus0.65 / 2.6Everyday main model for Qwen Code and daily coding tasks
qwen-maxQwen3.8-Max3.25 / 9.75Complex refactors, architecture and long context up to 1M tokens
Rates as of 4 November 2026. Current rates at /l/en/twelver-coding-api.

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
deepseekDeepSeek V4 Pro$217 per month
request: $0.0721,000 requests: $72.23
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.

Using Qwen3.8-Max and Qwen3.7-Plus inside IDE agents

If you also code inside an IDE, the exact same Base URL, sk-… key and series names (qwen / qwen-max) drop straight into:

Want a ready shell snippet

Ask the AI to configure Qwen Code for your project

Opens chat with the question pre-filled — just hit send. The API integrator issues your base_url and key, writes shell commands for macOS, Linux or Windows PowerShell and estimates token spend.

Common Qwen Code setup errors

SymptomCauseFix
Opens browser OAuth login instead of APIOne of the three OPENAI_* env vars is unsetExport OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL together, then run /auth
401 / UnauthorizedKey is not exported in the active terminal sessionRun source ~/.zshrc and verify echo $OPENAI_API_KEY
404 on requestTrailing slash after /v1 or wrong config-idEnsure OPENAI_BASE_URL ends in /v1 with no trailing slash
Model not foundUsing a vendor checkpoint name instead of a seriesUse the short series name: qwen, qwen-max or qwen-flash

Read next

Python SDK and Alibaba Cloud Model Studio details: Qwen API. Other coding agents on the same key: OpenCode, Cline, Kilo Code. Full book: API for AI coding agents.

Frequently asked questions

How do I connect Qwen Code to my own API?
Install @qwen-code/qwen-code, export OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL (for example qwen or qwen-max), launch qwen and pick OpenAI-compatible mode via /auth.
Should I use qwen or qwen-max in Qwen Code?
Start with qwen (Qwen3.7-Plus) for everyday coding — it is faster and much cheaper. Switch to qwen-max (Qwen3.8-Max) for tough architecture, large refactors and long-context tasks.
Can I run Qwen Code without an Alibaba Cloud account?
Yes. Through Twelver you get qwen-flash, qwen (Qwen3.7-Plus) and qwen-max (Qwen3.8-Max) over an OpenAI-compatible API, with a key issued on this page without signup or a card.
Does Qwen Code work on Windows?
Yes, with Node.js 20+. In PowerShell set $env:OPENAI_BASE_URL, $env:OPENAI_API_KEY and $env:OPENAI_MODEL (or place them in a project .env file).
How does Qwen Code compare to OpenCode?
Qwen Code is streamlined around Qwen and configured via three env vars. OpenCode is handy when you want multiple vendors (Qwen, DeepSeek, GPT, GLM, Grok) in one JSON config plus a separate cheap small_model.

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