{"slug": "run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup", "title": "Run Qwen 4 Max inside Claude Code via OpenRouter (~/.zshrc setup)", "summary": "A developer published a shell configuration that routes Claude Code through OpenRouter to run Qwen 4 Max as the backing model, using a subshell function in ~/.zshrc so the override applies only to that session. The setup sets ANTHROPIC_BASE_URL to OpenRouter's API, points all model variables at qwen/qwen4-max, and enables the /effort reasoning switch while leaving plain `claude` on its normal configuration.", "body_md": "|  | # Run Qwen 4 Max inside Claude Code via OpenRouter | \n|  | # From the video \"Qwen 4 Max: I made it edit my video (setup + honest take)\" | \n|  | # | \n|  | # 1. Create an OpenRouter API key (openrouter.ai → Workspaces → Keys → New key; set a credit limit) | \n|  | # 2. Paste this at the end of ~/.zshrc (macOS) and put your key in | \n|  | # 3. Run: source ~/.zshrc | \n|  | # 4. Start it with: claude-qwen (plain `claude` stays on your normal setup) | \n|  | # Use /effort to switch reasoning: low → low, medium/high → high, xhigh/max → extra high | \n|  | claude-qwen() ( # ( ) = subshell: these vars only apply to this run | \n|  | export ANTHROPIC_BASE_URL=\"https://openrouter.ai/api\" | \n|  | export ANTHROPIC_AUTH_TOKEN=\"<your OpenRouter key>\" # never commit or share your real key | \n|  | export ANTHROPIC_API_KEY=\"\" # keep empty so Claude Code uses OpenRouter | \n|  | export ANTHROPIC_MODEL=\"qwen/qwen4-max\" # must match the model id on OpenRouter | \n|  | export ANTHROPIC_DEFAULT_OPUS_MODEL=\"qwen/qwen4-max\" | \n|  | export ANTHROPIC_DEFAULT_SONNET_MODEL=\"qwen/qwen4-max\" | \n|  | export ANTHROPIC_DEFAULT_HAIKU_MODEL=\"qwen/qwen4-max\" | \n|  | export CLAUDE_CODE_SUBAGENT_MODEL=\"qwen/qwen4-max\" | \n|  | export CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 # unlocks /effort | \n|  | claude \"$@\" | \n|  | ) |", "url": "https://wpnews.pro/news/run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup", "canonical_source": "https://gist.github.com/nidhi-singh02/c5dd2473aafd04a0c214f3f73246d31b", "published_at": "2026-11-18 10:13:11+00:00", "updated_at": "2026-11-19 02:12:51.170216+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "ai-agents", "developer-tools"], "entities": ["Qwen", "Claude Code", "OpenRouter", "Anthropic"], "also_reported_by": [], "takeaway": "Wrapping the Claude Code launch in a zsh subshell function that exports ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN and the model variables lets you run Qwen 4 Max via OpenRouter without disturbing your default `claude` setup.", "recommendation": {"advice": "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.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup", "markdown": "https://wpnews.pro/news/run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup.md", "text": "https://wpnews.pro/news/run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup.txt", "jsonld": "https://wpnews.pro/news/run-qwen-4-max-inside-claude-code-via-openrouter-zshrc-setup.jsonld"}}