CLI & IDE Agents

Qwen Code

Use Alibaba's Qwen Code with FinOps for AI-powered coding with any provider, virtual keys, and observability.

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

If your Allowed Headers are already set to *, you can skip this note. If not and you face issues integrating FinOps with Qwen Code, try switching to * or adding the specific headers required by your client. By default, FinOps whitelists: Content-Type, Authorization, X-Requested-With, X-Stainless-Timeout, and X-Api-Key.

Setup

1. Install Qwen Code

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

2. Configure FinOps as a Model Provider

Qwen Code uses ~/.qwen/settings.json to configure model providers. Add FinOps as an OpenAI-compatible provider:

{
 "modelProviders": {
 "openai": [
 {
 "id": "openai/gpt-5",
 "name": "GPT-5 (via FinOps)",
 "baseUrl": "{AI_GATEWAY_URL}/openai",
 "envKey": "OPENAI_API_KEY"
 },
 {
 "id": "anthropic/claude-sonnet-4-5-20250929",
 "name": "Claude Sonnet 4.5 (via FinOps)",
 "baseUrl": "{AI_GATEWAY_URL}/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 FinOps virtual key or provider API key:

export OPENAI_API_KEY=your-finops-virtual-key

Alternatively, use a .env file in ~/.qwen/.env:

OPENAI_API_KEY=your-finops-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 FinOps 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 FinOps 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

FinOps 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 FinOps baseUrl and envKey.

Supported Providers

FinOps 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 FinOps via a single OpenAI-compatible endpoint. FinOps handles routing to the correct provider based on the model name - no per-provider configuration needed.

Observability

All Qwen Code traffic through FinOps is logged. Monitor it at {AI_GATEWAY_URL}/logs - filter by provider, model, or search through conversation content to track usage.

Next Steps