Coding tools
Qwen Code
Add Deference to Qwen Code as an OpenAI-compatible model provider.
Qwen Code reads model providers from modelProviders in settings.json. The openai provider speaks Chat Completions, so the base URL is https://deference.si/v1: use the root, not the full path.
Set up
- Create a key in API keys and export it as
DEFERENCE_API_KEY, or add it to~/.qwen/.envasDEFERENCE_API_KEY=sk-df-.... - Add the provider to
~/.qwen/settings.json(on Windows,%USERPROFILE%\.qwen\settings.json).
{
"modelProviders": {
"openai": [
{
"id": "anthropic/claude-sonnet-5.5",
"name": "Claude Sonnet 5.5 (Deference)",
"baseUrl": "https://deference.si/v1",
"envKey": "DEFERENCE_API_KEY",
"generationConfig": {
"contextWindowSize": 200000,
"samplingParams": { "max_tokens": 32000 }
}
}
]
},
"security": { "auth": { "selectedType": "openai" } },
"model": { "name": "anthropic/claude-sonnet-5.5" }
}- Start
qwen.
Do not put the key in the env block of settings.json or pass it with --openai-api-key. Both keep it where it can leak. envKey names the variable, so the key stays in your environment.
Verify
- Inside a session, run
/doctor. It checks the auth and environment. - Run
/model. The entry is listed. - Run a one-off prompt.
qwen -m anthropic/claude-sonnet-5.5 -p "Reply with exactly: gateway-ok"- Open Activity. The request is the top row, with the model you chose.
Pick a model
- Pick a model with
/model,-m, ormodel.namein the settings. - Put the limits inside the entry, in
generationConfig. Amodel.generationConfigat the top level does not apply to provider models. - Add
"wireApi": "responses"to an entry to send it toPOST /v1/responses. The default ischat-completions. - Edits to
modelProvidersapply without a restart.
Troubleshooting
| You see | Cause | Fix |
|---|---|---|
401 invalid_api_key | DEFERENCE_API_KEY is not set where Qwen Code starts | Export it in that shell, or add it to ~/.qwen/.env |
The model is not in /model | The provider key is not openai, or the entry is wrapped in an object | Use a bare array under modelProviders.openai |
| Qwen Code asks you to sign in with Qwen | selectedType is not set | Set security.auth.selectedType to openai |
404 | baseUrl is the full path, or lacks /v1 | Use https://deference.si/v1 |
404 model_not_found | id differs from the catalog | Copy the id from the Models page |