# Run Qwen 4 Max inside Claude Code via OpenRouter (~/.zshrc setup)

> Source: <https://gist.github.com/nidhi-singh02/c5dd2473aafd04a0c214f3f73246d31b>
> Published: 2026-11-18 10:13:11+00:00

**Recommendation:** Route Claude Code to an alternative model through OpenRouter by exporting the base URL, auth token and model IDs inside a subshell function so your default configuration stays untouched.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

|  | # Run Qwen 4 Max inside Claude Code via OpenRouter | 
|  | # From the video "Qwen 4 Max: I made it edit my video (setup + honest take)" | 
|  | # | 
|  | # 1. Create an OpenRouter API key (openrouter.ai → Workspaces → Keys → New key; set a credit limit) | 
|  | # 2. Paste this at the end of ~/.zshrc (macOS) and put your key in | 
|  | # 3. Run: source ~/.zshrc | 
|  | # 4. Start it with: claude-qwen (plain `claude` stays on your normal setup) | 
|  | # Use /effort to switch reasoning: low → low, medium/high → high, xhigh/max → extra high | 
|  | claude-qwen() ( # ( ) = subshell: these vars only apply to this run | 
|  | export ANTHROPIC_BASE_URL="https://openrouter.ai/api" | 
|  | export ANTHROPIC_AUTH_TOKEN="<your OpenRouter key>" # never commit or share your real key | 
|  | export ANTHROPIC_API_KEY="" # keep empty so Claude Code uses OpenRouter | 
|  | export ANTHROPIC_MODEL="qwen/qwen4-max" # must match the model id on OpenRouter | 
|  | export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen/qwen4-max" | 
|  | export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen/qwen4-max" | 
|  | export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen/qwen4-max" | 
|  | export CLAUDE_CODE_SUBAGENT_MODEL="qwen/qwen4-max" | 
|  | export CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 # unlocks /effort | 
|  | claude "$@" | 
|  | ) |
