Multi-provider launcher for Claude Code with unified configuration management.
QAI transparently routes Claude Code to different AI providers by intercepting API calls and translating between provider-specific formats. It supports both direct Anthropic-compatible endpoints and NVIDIA NIM endpoints that require protocol translation.
- Multi-provider support: Switch between different AI providers via command-line
- Automatic proxy: NVIDIA NIM endpoints automatically go through a translation proxy
- Unified configuration: Single YAML file manages all provider credentials
- Clean process management: Proper cleanup of proxy and Claude processes
- Environment injection: Provider-specific environment variables for Claude Code
┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
│ Claude Code │───────▶ │ QAI │───────▶ │ Provider │
│ │ STDIO │ │ HTTP │ │
└─────────────────┘ └─────────────────┘ └──────────────┘
│ ↑ ↑
│ │ Proxy (NVIDIA only) │
└──┴─────────────────────────┘
Two modes:
- Direct mode: Claude Code connects directly to provider (Anthropic-compatible)
- Proxy mode: QAI starts an HTTP proxy that translates between Claude Code and NVIDIA NIM
Create configuration file:
mkdir -p ~/.config/qai
touch ~/.config/qai/config.yaml# Optional: Set default provider
default: zai
# Provider definitions
providers:
# Provider name (used with -p flag)
zai:
# Provider type: "zai" (default, Anthropic-compatible) or "nvidia"
provider: "zai"
# API authentication token
token: "your-token-here"
# Optional: Environment variables to pass to Claude Code
env:
ANTHROPIC_DEFAULT_OPUS_MODEL: "GLM-5"
nim:
provider: "nvidia"
token: "nvapi-xxxxxxxxxxxxxxxxxxxxxxxxxx"
# Optional: Custom base URL (defaults to NVIDIA endpoint)
# base_url: "https://custom-nvidia-endpoint/v1"
# Custom Anthropic-compatible endpoint
custom:
provider: "zai"
token: "sk-ant-xxxxxxxx"
base_url: "https://api.custom-provider.com/v1"| Type | Description | Needs Proxy | Base URL Default |
|---|---|---|---|
zai |
Anthropic-compatible (Claude API format) | No | https://api.z.ai/api/anthropic |
nvidia |
NVIDIA NIM (requires translation) | Yes | https://integrate.api.nvidia.com/v1/chat/completions |
# Use default provider
qai claude
# Specify provider by name
qai -p zai claude
qai -p nim claude
# Pass arguments to Claude Code
qai claude --help
qai -p zai claude /path/to/repoStart the translation proxy without launching Claude:
qai -p nim proxyOutput will show the local proxy port (e.g., :58473):
nim proxy on :58473
You can then test the proxy:
curl http://127.0.0.1:58473/v1/messages \
-H "X-Api-Key: test" \
-H "Content-Type: application/json" \
-d '{"model":"claude-3-5-sonnet","messages":[]}'| Field | Required When | Description |
|---|---|---|
token |
Always | API authentication token |
base_url |
Custom endpoints | Override default provider endpoint |
| Field | Description |
|---|---|
provider |
Provider type or "zai" (default) |
env |
Additional environment variables for Claude Code |
model |
Model name to pass to Claude Code |
The following environment variables are automatically set:
ANTHROPIC_AUTH_TOKEN: Set to provider tokenANTHROPIC_BASE_URL: Set to proxy URL (for NVIDIA) or custom base URLANTHROPIC_MODEL: Set to provider's model if specified
Additional variables from the provider's env field are merged into Claude Code's environment.
Create the configuration file or specify a provider with -p:
qai -p zai claudeCheck that the provider name in your config matches what you're using with -p.
Add a token field to the provider configuration in ~/.config/qai/config.yaml.
The proxy command only works with providers that require a proxy (currently only nvidia type).
QAI registers signal handlers for SIGINT, SIGTERM, and others to ensure proper cleanup. If processes remain, manually kill them:
# Find proxy processes
ps aux | grep nvidia-claude-proxy
# Kill process tree
kill -9 -<PID>