Command-line agents
Qwen Code
Let the Qwen Code terminal agent use NoviaHub models over the OpenAI-compatible protocol.
Qwen Code describes itself as “the open-source AI coding agent for your terminal, editor, desktop, browser, and chat”. It supports the OpenAI, Anthropic, Gemini and Qwen APIs. This page connects it to NoviaHub over its OpenAI-compatible protocol.
Prerequisites
Section titled “Prerequisites”- A NoviaHub account with an API key. See API keys.
- Funds in your account. See Wallet and top-ups.
Install Qwen Code
Section titled “Install Qwen Code”curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.sh | bashirm https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.ps1 | iexInstalling with npm needs Node.js 22 or later:
npm install -g @qwen-code/qwen-code@latest# or (macOS / Linux)brew install qwen-codeAfter installing, restart your terminal so the environment variables take effect.
Configure NoviaHub
Section titled “Configure NoviaHub”-
Store the key in the environment variable
NOVIAHUB_API_KEY.终端窗口 # macOS uses zsh by default; with bash on Linux, use ~/.bashrc instead of ~/.zshrcecho 'export NOVIAHUB_API_KEY="sk-..."' >> ~/.zshrcsource ~/.zshrc终端窗口 setx NOVIAHUB_API_KEY "sk-..."setxdoes not affect the current window; close the terminal and open a new one. -
Edit the config file
~/.qwen/settings.json(create it if needed) and add:~/.qwen/settings.json {"modelProviders": {"openai": [{"id": "deepseek-v4-flash","name": "deepseek-v4-flash","baseUrl": "https://noviahub.com/v1","envKey": "NOVIAHUB_API_KEY"}]},"security": {"auth": {"selectedType": "openai"}},"model": {"name": "deepseek-v4-flash"}}Setting Purpose modelProviders.openaiThe models that use the OpenAI-compatible protocol, one entry per model. idThe model ID. It must match the model ID on NoviaHub exactly. nameThe name shown in the /modelpicker; defaults toid.baseUrlThe API address, up to /v1:https://noviahub.com/v1. Don’t enter.../v1/chat/completions; Qwen Code appends the request path itself.envKeyThe environment variable that holds the key. security.auth.selectedTypeWhich protocol to use at startup, here openai. With it set, you don’t have to choose in/autheach time.model.nameThe default model at startup. It must be the idof one of the entries above.If
settings.jsonalready has other content, merge these fields into it; don’t end up with two top-level fields of the same name. -
Run
qwen. With a correct config, you don’t need the interactive/authsetup.
Alternative: environment variables only
Section titled “Alternative: environment variables only”If you’d rather not write a config file, you can set just these three variables. Qwen Code’s docs say that to select OpenAI-compatible auth with environment variables alone, OPENAI_API_KEY must be set.
export OPENAI_API_KEY="sk-..." # your NoviaHub keyexport OPENAI_BASE_URL="https://noviahub.com/v1"export OPENAI_MODEL="deepseek-v4-flash"qwenVerify
Section titled “Verify”-
Run
/doctorin Qwen Code to check the current authentication. -
Send something simple, such as “Introduce yourself in one sentence.” A reply means the setup works.
-
Check the call and its cost under Usage Logs in the NoviaHub console.
Switch and add models
Section titled “Switch and add models”- Add a model: add another entry to
modelProviders.openai(it needs at least anid), copyingbaseUrlandenvKeyfrom the first. A running session picks up changes tosettings.jsonautomatically; reopen/modelto see them. - Switch models: run
/modelin a session, or choose at launch:qwen --model "kimi-k3". - Which models: the default is the Chat Completions API, so pick models that carry the Chat label under Models & Pricing. Every model on the site carried it on 2026-09-28.
- Use the Responses API: add
"wireApi": "responses"to a model’s entry and Qwen Code uses the Responses API for it. This only works for models whose page shows the Response label (for examplegpt-6-sol).
- Where the key is read from, highest priority first: command-line flags (such as
--openai-api-key) → environment variables exported in the shell → a.envfile → theenvfield insettings.json. Only the first.envfile found is loaded: Qwen Code looks for.qwen/.envand then.envfrom the current directory upward, and if neither exists,~/.qwen/.envand then~/.env. - Avoid putting the key in the
envfield ofsettings.json: it is stored in plain text there. Qwen Code recommends.envfiles orexportinstead. - Keep it in your user settings: Qwen Code recommends defining
modelProvidersin the user-level~/.qwen/settings.jsonto avoid conflicts with project settings.
References
Section titled “References”Checked on 2026-09-28:
- Qwen Code repository and install: https://github.com/QwenLM/qwen-code
- Authentication and settings.json: https://qwenlm.github.io/qwen-code-docs/en/users/configuration/auth/
- Model providers (
baseUrl,wireApi): https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/