> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modellix.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Modellix LLM with Qwen Code

> Point Qwen Code at the Modellix LLM gateway with OPENAI_BASE_URL, OPENAI_API_KEY, and provider/name model IDs.

Configure [Qwen Code](https://github.com/QwenLM/qwen-code) to call the Modellix LLM gateway. Qwen Code supports OpenAI-compatible endpoints through environment variables or [`modelProviders`](https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/) in `settings.json`, pointed at Chat Completions on [`POST /v1/chat/completions`](/llm/chat-completions).

<Note>
  This page covers **LLM text** only (`https://llm.modellix.ai`).

  Modellix model IDs are `provider/name` (for example `openai/gpt-5.5`). Set that full string as `OPENAI_MODEL` or as each `modelProviders` model `id`. See [Models & Pricing](/llm/overview#models-and-pricing).
</Note>

## Set Up Qwen Code

<Steps>
  <Step title="Install Qwen Code">
    Requires Node.js 20+. Install the global CLI:

    ```bash theme={null}
    npm install -g @qwen-code/qwen-code
    qwen --version
    ```
  </Step>

  <Step title="Set Environment Variables">
    Point the OpenAI-compatible client at Modellix (same pattern as the [OpenAI SDK](/llm/sdk/openai-sdk)):

    ```bash theme={null}
    export OPENAI_API_KEY="mdlx-xxxxxxxx"
    export OPENAI_BASE_URL="https://llm.modellix.ai/v1"
    export OPENAI_MODEL="openai/gpt-5.5"
    ```

    Add these lines to your shell profile (for example `~/.zshrc`), then run `source ~/.zshrc`.

    | Setting           | Value                                                                    |
    | ----------------- | ------------------------------------------------------------------------ |
    | `OPENAI_API_KEY`  | Modellix API Key from the [console](https://modellix.ai/console/api-key) |
    | `OPENAI_BASE_URL` | `https://llm.modellix.ai/v1` (include `/v1`)                             |
    | `OPENAI_MODEL`    | Exact Modellix Model ID (`provider/name`)                                |

    <Warning>
      Use a Modellix API key, not an OpenAI platform key. Do not set `OPENAI_BASE_URL` to the media API host (`https://api.modellix.ai`).
    </Warning>
  </Step>

  <Step title="Optional: Persist in settings.json">
    For multiple models or a durable project/user config, declare Modellix under the `openai` auth type in `~/.qwen/settings.json` (or `.qwen/settings.json` in a project):

    ```json theme={null}
    {
      "env": {
        "MODELLIX_API_KEY": "mdlx-xxxxxxxx"
      },
      "modelProviders": {
        "openai": {
          "protocol": "openai",
          "models": [
            {
              "id": "openai/gpt-5.5",
              "name": "GPT 5.5",
              "baseUrl": "https://llm.modellix.ai/v1",
              "envKey": "MODELLIX_API_KEY"
            },
            {
              "id": "anthropic/claude-sonnet-5",
              "name": "Claude Sonnet 5",
              "baseUrl": "https://llm.modellix.ai/v1",
              "envKey": "MODELLIX_API_KEY"
            },
            {
              "id": "google/gemini-3.6-flash",
              "name": "Gemini 3.6 Flash",
              "baseUrl": "https://llm.modellix.ai/v1",
              "envKey": "MODELLIX_API_KEY"
            }
          ]
        }
      },
      "security": {
        "auth": {
          "selectedType": "openai"
        }
      },
      "model": {
        "name": "openai/gpt-5.5"
      }
    }
    ```

    Replace `mdlx-xxxxxxxx` with your Modellix API key, or keep the key only in the process environment and omit the `env` block. Credentials in `modelProviders` are read from `process.env[envKey]`, not stored as plaintext API fields.

    <Tip>
      You do **not** need a separate Anthropic `baseUrl` without `/v1` for these IDs. Register `anthropic/...` and `google/...` on the same Modellix OpenAI-compatible `baseUrl`; traffic goes through Chat Completions on `https://llm.modellix.ai/v1`. Native Anthropic Messages is for the [Anthropic SDK](/llm/sdk/anthropic-sdk) and [Claude Code](/llm/agent/claude-code).
    </Tip>
  </Step>

  <Step title="Start Qwen Code">
    From your project directory:

    ```bash theme={null}
    qwen
    ```

    Run `/about` to confirm the active model and endpoint. Use `/model` to switch among entries declared in `modelProviders`.
  </Step>
</Steps>

## Troubleshooting

| Symptom                   | Check                                                                                           |
| ------------------------- | ----------------------------------------------------------------------------------------------- |
| 401 / auth errors         | `OPENAI_API_KEY` or `MODELLIX_API_KEY` is a valid Modellix key                                  |
| Model not found / 404     | Model ID is a full string like `openai/gpt-5.5`, not bare `gpt-5.5`                             |
| Wrong path / URL errors   | `OPENAI_BASE_URL` / `baseUrl` is `https://llm.modellix.ai/v1` (include `/v1`)                   |
| Still hitting OpenAI      | Base URL is Modellix; `/about` shows the expected endpoint                                      |
| Model missing in `/model` | Entry exists under `modelProviders.openai.models` with matching `envKey` set in the environment |

## Related

* [Qwen Code model providers](https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/) — `modelProviders` schema
* [Models & Pricing](/llm/overview#models-and-pricing) — Model IDs and rates
* [LLM API guide](/llm/api/api) — protocols and curl examples
* [OpenAI SDK](/llm/sdk/openai-sdk) — same `OPENAI_BASE_URL` + `/v1` pattern
* [OpenCode](/llm/agent/opencode) — another OpenAI-compatible coding agent setup
