Skip to main content
Qwen Code is Alibaba’s powerful coding assistant with advanced reasoning capabilities. By connecting it to Bifrost, you get access to any provider/model in your Bifrost configuration, plus governance features like virtual keys and built-in observability.

Setup

1. Install Qwen Code

npm install -g @qwen-code/qwen-code

2. Configure Bifrost as a Model Provider

Qwen Code uses ~/.qwen/settings.json to configure model providers. Add Bifrost as an OpenAI-compatible provider:
{
  "modelProviders": {
    "openai": [
      {
        "id": "openai/gpt-5",
        "name": "GPT-5 (via Bifrost)",
        "baseUrl": "http://localhost:8080/openai",
        "envKey": "OPENAI_API_KEY"
      },
      {
        "id": "anthropic/claude-sonnet-4-5-20250929",
        "name": "Claude Sonnet 4.5 (via Bifrost)",
        "baseUrl": "http://localhost:8080/openai",
        "envKey": "OPENAI_API_KEY"
      }
    ]
  },
  "security": {
    "auth": {
      "selectedType": "openai"
    }
  },
  "model": {
    "name": "openai/gpt-5"
  }
}

3. Set Your API Key

Set the OPENAI_API_KEY environment variable to your Bifrost virtual key or provider API key:
export OPENAI_API_KEY=your-bifrost-virtual-key
Alternatively, use a .env file in ~/.qwen/.env:
OPENAI_API_KEY=your-bifrost-virtual-key

4. Run Qwen Code

qwen
You can also use environment variables for a minimal setup. Set OPENAI_BASE_URL and OPENAI_API_KEY, then run qwen. Note: some Qwen Code versions prioritize settings.json over env vars — use settings.json for reliable configuration.

Virtual Keys

When Bifrost has virtual key authentication enabled, set OPENAI_API_KEY to your virtual key. This lets you enforce usage limits, budgets, and access control per user or environment. For team deployments, create a separate virtual key for each team — each key can have its own rate limits, budgets, and provider access rules configured in the Bifrost dashboard.

Model Selection

Use the /model command to switch between models at runtime. All models configured in your modelProviders appear in the picker.
# Launch with a specific model
qwen --model "anthropic/claude-sonnet-4-5-20250929"
  • Use powerful models like openai/gpt-5 or anthropic/claude-sonnet-4-5-20250929 for complex coding tasks
  • Use fast models like groq/llama-3.3-70b-versatile for quick completions

Using Multiple Providers

Bifrost routes requests to the correct provider based on the model name. Use the provider/model-name format in your modelProviders config to access any configured provider through the single OpenAI endpoint:
anthropic/claude-sonnet-4-5-20250929
openai/gpt-5
gemini/gemini-2.5-pro
mistral/mistral-large-latest
Add multiple models to your modelProviders.openai array — they all use the same Bifrost baseUrl and envKey.

Supported Providers

Bifrost supports the following providers with the provider/model-name format: openai, azure, gemini, vertex, bedrock, mistral, groq, cerebras, cohere, perplexity, xai, ollama, openrouter, huggingface, nebius, parasail, replicate, vllm, sgl
Non-native models must support tool use for Qwen Code to work properly. Qwen Code relies on tool calling for file operations, terminal commands, and code editing. Models without tool use support will fail on most operations.
Qwen Code connects to Bifrost via a single OpenAI-compatible endpoint. Bifrost handles routing to the correct provider based on the model name — no per-provider configuration needed.

Observability

All Qwen Code traffic through Bifrost is logged. Monitor it at http://localhost:8080/logs — filter by provider, model, or search through conversation content to track usage.

Next Steps