# Qwen

Source: https://docs.aicentos.com/en/clients/qwen

Language: en

> Use aicentos in Qwen Code — configure an OpenAI-compatible provider through settings.json

Qwen Code can register any OpenAI-compatible endpoint through `modelProviders` in `settings.json`. Point `baseUrl` at aicentos and the models aicentos offers become usable in Qwen Code.

## Prerequisites

First create a dedicated key for Qwen Code on the console's "API Keys" page (naming it `qwen-code` makes usage easier to track).

* Console: [https://aicentos.com](https://aicentos.com)
* Create a key: [https://aicentos.com/keys](https://aicentos.com/keys)
* Wallet top-up: [https://aicentos.com/wallet](https://aicentos.com/wallet)
* Docs site: [https://docs.aicentos.com](https://docs.aicentos.com)

Qwen Code requires Node.js 20+; install globally with npm:

```bash
npm install -g @qwen-code/qwen-code
qwen --version
```

## Configuration to fill in

| Field     | Value                                                           |
| --------- | --------------------------------------------------------------- |
| auth type | `openai` (OpenAI-compatible protocol)                           |
| baseUrl   | `https://aicentos.com/v1`                                       |
| envKey    | Name of the environment variable holding the key (customizable) |
| Model id  | A model name from the Model Gallery in the console              |

## Setup steps

Edit `~/.qwen/settings.json`:

```json
{
  "env": {
    "AICENTOS_API_KEY": "sk-your-Key"
  },
  "modelProviders": {
    "openai": [
      {
        "id": "gpt-4o",
        "name": "GPT-4o",
        "baseUrl": "https://aicentos.com/v1",
        "envKey": "AICENTOS_API_KEY"
      }
    ]
  },
  "security": {
    "auth": {
      "selectedType": "openai"
    }
  },
  "model": {
    "name": "gpt-4o"
  }
}
```

* `id` is the model ID actually sent to the server and must match the model name in the console.
* Do not put a plain-text key in `modelProviders`; `envKey` is just a reference to which environment variable holds the key.
* Key precedence: system environment variables > `.env` file (`~/.qwen/.env`) > the `env` block in `settings.json`.
* If the aicentos side uses the Responses protocol, add `"wireApi": "responses"` to that model; when omitted it defaults to Chat Completions.

Alternatively, skip the configuration file entirely and use environment variables:

```bash
export OPENAI_BASE_URL="https://aicentos.com/v1"
export OPENAI_API_KEY="sk-your-Key"
export OPENAI_MODEL="gpt-4o"
```

## Test

Start `qwen`, use `/about` to confirm the current endpoint and model are correct, then send a simple prompt. With multiple provider entries configured, you can switch with `/model`.

## Notes

* Global configuration lives in `~/.qwen/settings.json`; project-level configuration lives in `.qwen/settings.json` at the project root, which takes precedence.
* `security.auth.selectedType` must be `openai`, otherwise the custom endpoint is not used.
* Never commit a plain-text key to version control; prefer `~/.qwen/.env` or system environment variables.
* `wireApi` is only local routing metadata and is not sent in the request body; before switching it to `responses`, confirm that the aicentos side supports `/v1/responses`.
* Enter the Base URL only up to `/v1`; do not extend it to the full endpoint path.