Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JustSuperHuman/cda6981a62aa4fd2e2ba8120a717b348 to your computer and use it in GitHub Desktop.

Select an option

Save JustSuperHuman/cda6981a62aa4fd2e2ba8120a717b348 to your computer and use it in GitHub Desktop.
Openrouter Fusion in Claude Code :))
Set up a separate `or` command that launches Claude Code through OpenRouter, without changing or
interfering with my normal Claude Code setup.
Requirements:
1. Ask me for my OpenRouter API key before making changes.
- Do not print the key back to me.
- Store it securely enough for normal shell use:
- On macOS/Linux: add it to my shell profile as `OPENROUTER_API_KEY`, unless a better local
convention already exists.
- On Windows: store it as a User environment variable named `OPENROUTER_API_KEY`.
- Do not hardcode the key directly inside the `or` function if avoidable.
2. Create an `or` command/function that runs Claude Code with:
- OpenRouter base URL: `https://openrouter.ai/api`
- Auth token from `OPENROUTER_API_KEY`
- `ANTHROPIC_API_KEY` explicitly blanked
- Separate Claude config directory so it does not affect my normal Claude usage:
- macOS/Linux: `$HOME/.claude-openrouter`
- Windows: `$HOME\.claude-openrouter`
- Model: `openrouter/fusion`
- Skip permissions enabled, same as:
`claude --dangerously-skip-permissions --model "openrouter/fusion"`
3. Make this work in new terminals:
- On macOS/Linux:
- Detect my shell using `$SHELL`.
- For zsh, update `~/.zshrc`.
- For bash, update `~/.bashrc` or `~/.bash_profile` as appropriate.
- For fish, update `~/.config/fish/config.fish` using fish syntax.
- On Windows:
- Update both PowerShell 7 and Windows PowerShell current-user profiles if they exist or may be
used:
- `$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`
- `$HOME\Documents\PowerShell\profile.ps1`
- `$HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`
- `$HOME\Documents\WindowsPowerShell\profile.ps1`
- Preserve existing profile content.
- Do not remove existing functions like `claude`, `clawd`, aliases, or custom helpers.
4. Avoid duplicate setup:
- If an `or` function already exists, replace only the managed `or` block or ask before
overwriting if it appears user-authored.
- Add clear begin/end comments around the managed block, for example:
`# BEGIN OpenRouter Claude Code wrapper`
`# END OpenRouter Claude Code wrapper`
5. Verify after setup:
- Start a fresh shell process or source the edited profile.
- Confirm `or` resolves as a command/function.
- Run `or --version` or the safest equivalent to verify Claude Code launches through the wrapper
without starting a full agent session.
- Do not run a long interactive Claude session unless I explicitly approve it.
6. Explain what changed:
- List the profile files edited.
- Confirm the key was stored without displaying it.
- Confirm normal `claude` and existing commands still use the original Claude setup.
- Tell me to open a new terminal and run:
`or`
Use these model details:
- Main model slug: `openrouter/fusion`
- Fusion panel I want conceptually:
- `anthropic/claude-opus-4.8`
- `google/gemini-3.1-pro-preview`
- `openai/gpt-5.5`
Important caveat:
Claude Code can pass the `openrouter/fusion` model slug, but may not be able to pass OpenRouter
Fusion plugin request-body fields like `analysis_models`. If exact panel customization is not
possible through Claude Code CLI, still set up `or` with `openrouter/fusion` and tell me clearly
what limitation remains.
Implementation examples:
PowerShell function should look like this:
function or {
if (-not $env:OPENROUTER_API_KEY) {
throw "OPENROUTER_API_KEY is not set. Restart PowerShell or set it in your user environment."
}
$env:CLAUDE_CONFIG_DIR = Join-Path $HOME ".claude-openrouter"
$env:ANTHROPIC_BASE_URL = "https://openrouter.ai/api"
$env:ANTHROPIC_AUTH_TOKEN = $env:OPENROUTER_API_KEY
$env:ANTHROPIC_API_KEY = ""
& claude --dangerously-skip-permissions --model "openrouter/fusion" @args
}
zsh/bash function should look like this:
or() {
if [ -z "$OPENROUTER_API_KEY" ]; then
echo "OPENROUTER_API_KEY is not set. Restart your shell or set it in your environment." >&2
return 1
fi
CLAUDE_CONFIG_DIR="$HOME/.claude-openrouter" \
ANTHROPIC_BASE_URL="https://openrouter.ai/api" \
ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" \
ANTHROPIC_API_KEY="" \
claude --dangerously-skip-permissions --model "openrouter/fusion" "$@"
}
fish function should use fish syntax and preserve argument forwarding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment