Qwen
Use aicentos in Qwen Code — configure an OpenAI-compatible provider through settings.json
Last updated:
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
- Create a key: https://aicentos.com/keys
- Wallet top-up: https://aicentos.com/wallet
- Docs site: https://docs.aicentos.com
Qwen Code requires Node.js 20+; install globally with npm:
npm install -g @qwen-code/qwen-code
qwen --versionConfiguration 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:
{
"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"
}
}idis 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;envKeyis just a reference to which environment variable holds the key. - Key precedence: system environment variables >
.envfile (~/.qwen/.env) > theenvblock insettings.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:
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.jsonat the project root, which takes precedence. security.auth.selectedTypemust beopenai, otherwise the custom endpoint is not used.- Never commit a plain-text key to version control; prefer
~/.qwen/.envor system environment variables. wireApiis only local routing metadata and is not sent in the request body; before switching it toresponses, 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.