Skip to content

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.

终端窗口
curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen-standalone.sh | bash

After installing, restart your terminal so the environment variables take effect.

  1. Store the key in the environment variable NOVIAHUB_API_KEY.

    终端窗口
    # macOS uses zsh by default; with bash on Linux, use ~/.bashrc instead of ~/.zshrc
    echo 'export NOVIAHUB_API_KEY="sk-..."' >> ~/.zshrc
    source ~/.zshrc
  2. 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.openai The models that use the OpenAI-compatible protocol, one entry per model.
    id The model ID. It must match the model ID on NoviaHub exactly.
    name The name shown in the /model picker; defaults to id.
    baseUrl The API address, up to /v1: https://noviahub.com/v1. Don’t enter .../v1/chat/completions; Qwen Code appends the request path itself.
    envKey The environment variable that holds the key.
    security.auth.selectedType Which protocol to use at startup, here openai. With it set, you don’t have to choose in /auth each time.
    model.name The default model at startup. It must be the id of one of the entries above.

    If settings.json already has other content, merge these fields into it; don’t end up with two top-level fields of the same name.

  3. Run qwen. With a correct config, you don’t need the interactive /auth setup.

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 key
export OPENAI_BASE_URL="https://noviahub.com/v1"
export OPENAI_MODEL="deepseek-v4-flash"
qwen
  1. Run /doctor in Qwen Code to check the current authentication.

  2. Send something simple, such as “Introduce yourself in one sentence.” A reply means the setup works.

  3. Check the call and its cost under Usage Logs in the NoviaHub console.

  • Add a model: add another entry to modelProviders.openai (it needs at least an id), copying baseUrl and envKey from the first. A running session picks up changes to settings.json automatically; reopen /model to see them.
  • Switch models: run /model in 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 example gpt-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 .env file → the env field in settings.json. Only the first .env file found is loaded: Qwen Code looks for .qwen/.env and then .env from the current directory upward, and if neither exists, ~/.qwen/.env and then ~/.env.
  • Avoid putting the key in the env field of settings.json: it is stored in plain text there. Qwen Code recommends .env files or export instead.
  • Keep it in your user settings: Qwen Code recommends defining modelProviders in the user-level ~/.qwen/settings.json to avoid conflicts with project settings.

Checked on 2026-09-28: