Skip to content

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

  1. Create a key in API keys and export it as DEFERENCE_API_KEY, or add it to ~/.qwen/.env as DEFERENCE_API_KEY=sk-df-....
  2. 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" }
}
  1. 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

  1. Inside a session, run /doctor. It checks the auth and environment.
  2. Run /model. The entry is listed.
  3. Run a one-off prompt.
qwen -m anthropic/claude-sonnet-5.5 -p "Reply with exactly: gateway-ok"
  1. Open Activity. The request is the top row, with the model you chose.

Pick a model

  • Pick a model with /model, -m, or model.name in the settings.
  • Put the limits inside the entry, in generationConfig. A model.generationConfig at the top level does not apply to provider models.
  • Add "wireApi": "responses" to an entry to send it to POST /v1/responses. The default is chat-completions.
  • Edits to modelProviders apply without a restart.

Troubleshooting

You seeCauseFix
401 invalid_api_keyDEFERENCE_API_KEY is not set where Qwen Code startsExport it in that shell, or add it to ~/.qwen/.env
The model is not in /modelThe provider key is not openai, or the entry is wrapped in an objectUse a bare array under modelProviders.openai
Qwen Code asks you to sign in with QwenselectedType is not setSet security.auth.selectedType to openai
404baseUrl is the full path, or lacks /v1Use https://deference.si/v1
404 model_not_foundid differs from the catalogCopy the id from the Models page