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.
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-codeCheck that the binary is on your PATH:
qwen --versionStep 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):
~/.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
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
qwenOn 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" qwenChoosing a Qwen series in Twelver API
| Series | Model | In / out, $ per 1M | Best for |
|---|---|---|---|
| qwen-flash | Qwen3.8-Flash | 0.244 / 0.764 | Fast housekeeping calls, drafts and quick file checks |
| auto / qwen | Qwen3.7-Plus | 0.65 / 2.6 | Everyday main model for Qwen Code and daily coding tasks |
| qwen-max | Qwen3.8-Max | 3.25 / 9.75 | Complex refactors, architecture and long context up to 1M tokens |
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 monthdeepseekDeepSeek V4 Pro$217 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.
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:
- Cline in VS Code — OpenAI Compatible provider, Model ID
qwenorqwen-max; - Kilo Code in VS Code, JetBrains and CLI — Custom provider with the same URL and key;
- OpenCode — lets you keep Qwen alongside DeepSeek, GLM, GPT and Grok in one JSON file and pin
qwen-flashassmall_model.
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
| Symptom | Cause | Fix |
|---|---|---|
| Opens browser OAuth login instead of API | One of the three OPENAI_* env vars is unset | Export OPENAI_BASE_URL, OPENAI_API_KEY and OPENAI_MODEL together, then run /auth |
| 401 / Unauthorized | Key is not exported in the active terminal session | Run source ~/.zshrc and verify echo $OPENAI_API_KEY |
| 404 on request | Trailing slash after /v1 or wrong config-id | Ensure OPENAI_BASE_URL ends in /v1 with no trailing slash |
| Model not found | Using a vendor checkpoint name instead of a series | Use 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?
Should I use qwen or qwen-max in Qwen Code?
Can I run Qwen Code without an Alibaba Cloud account?
Does Qwen Code work on Windows?
How does Qwen Code compare to OpenCode?
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