Qwen Code: Claude & GPT via OpenAI-Compatible
This guide needs an API key
Create an account and generate one in about a minute, then use it wherever the steps below expect a key.
No card required to sign up · API usage requires a top-up
Qwen Code is Alibaba's open-source terminal agent; its modelProviders setting accepts any OpenAI-compatible base URL, so one Code By AI key serves Claude and GPT.
Qwen Code is a terminal coding agent derived from Gemini CLI. It reads ~/.qwen/settings.json and can register several OpenAI-compatible models, which the /model picker switches between.
One command (macOS / Linux)
1 curl -fsSL https://www.codebyai.net/setup.sh | sh -s -- --qwen-code
It asks for your API key (hidden input), writes CODEBYAI_API_KEY to your shell rc file, and adds gpt-5.6-terra and claude-sonnet-5 to ~/.qwen/settings.json as the default models, backing the file up first. The key never goes into settings.json. With QWEN_HOME set, it edits the file there, as Qwen Code does. Re-running rotates the key and keeps the model you picked with /model; | sh -s -- --uninstall restores the file. Open a new terminal, then run qwen. Comments in settings.json do not survive the rewrite; the backup keeps them. The manual steps below do the same by hand.
1. Install Qwen Code
Node.js 22 or newer:
1 npm install -g @qwen-code/qwen-code@latest
On macOS or Linux, brew install qwen-code is an alternative. Check the install with qwen --version.
2. Create a Code By AI API key
Sign in to Code By AI, open API Keys, and create a key. It looks like sk-proj-....
3. Add the models to settings.json
Open ~/.qwen/settings.json (user level) and merge this into the existing object. Keep any providers already there:
1 {2 "modelProviders": {3 "openai": [4 {5 "id": "gpt-5.6-terra",6 "name": "CodeByAI GPT",7 "baseUrl": "https://www.codebyai.net/api/agent/v1",8 "envKey": "CODEBYAI_API_KEY"9 },10 {11 "id": "claude-sonnet-5",12 "name": "CodeByAI Claude",13 "baseUrl": "https://www.codebyai.net/api/agent/v1",14 "envKey": "CODEBYAI_API_KEY"15 }16 ]17 },18 "security": { "auth": { "selectedType": "openai" } },19 "model": { "name": "gpt-5.6-terra" }20 }
The openai provider ID means the OpenAI-compatible protocol. wireApi is omitted, so Chat Completions is used; the gateway serves both model families on that route. Do not add wireApi: "responses" unless you deliberately want the Responses API.
4. Export the key
Credentials are read from the environment, never stored in the settings file:
1 export CODEBYAI_API_KEY="sk-proj-xxxx"
Add that line to ~/.zshrc or ~/.bashrc, then start a new shell. If the variable is missing, Qwen Code skips the route or fails authentication instead of falling back silently.
5. Start Qwen Code
1 cd your-project2 qwen
Run /model, pick gpt-5.6-terra or claude-sonnet-5, and send a prompt. The picker stores the choice for the session.
Troubleshooting
- The models do not appear in
/model—modelProvidersis not a bare array, or the provider ID is not a built-in auth type. Use"openai": [ ... ]as shown. 401—CODEBYAI_API_KEYis not exported in the shell that startedqwen.echo $CODEBYAI_API_KEYshould print the key.404—baseUrlincludes/chat/completionsor duplicates/v1. Usehttps://www.codebyai.net/api/agent/v1.- Only one family works — confirm the model ID matches the Model Plaza;
claude-*is forwarded to the Claude channel, everything else is treated as a Codex-channel model.
Get started
Four steps to your first request
- 01
Create a free account
Sign up with Google, GitHub or email and set a password. No card is required.
- 02
Generate an API key
Create a key in one click from the dashboard. It lets your CLI authenticate with Code By AI.
- 03
Top up your balance
Add credit before your first request; usage is charged per token from your balance.
- 04
Point your CLI at Code By AI
Export one base-URL variable, or add a model provider block to config.toml. The setup guides list the exact lines for each agent.
No card required to sign up · API usage requires a top-up