Save this script somewhere in your $PATH, e.g.:
vi ~/bin/or_claude
chmod +x ~/bin/or_claudeReplace your_openrouter_api_key_here with your real key (or export OPENROUTER_API_KEY before running).
or_claude
| #!/usr/bin/env bash | |
| # File: or_claude | |
| # Wrapper script to run Claude Code with OpenRouter | |
| # ---- CONFIG ---- | |
| OPENROUTER_API_KEY="${OPENROUTER_API_KEY:-your_openrouter_api_key_here}" | |
| OPENROUTER_BASE_URL="https://openrouter.ai/api" | |
| # Optional: override models (comment out if not needed) | |
| OPENROUTER_MODEL="x-ai/grok-4.1-fast" | |
| # ---- SET ENV ---- | |
| export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY" | |
| export ANTHROPIC_BASE_URL="$OPENROUTER_BASE_URL" | |
| export ANTHROPIC_DEFAULT_HAIKU_MODEL="$OPENROUTER_MODEL" | |
| export ANTHROPIC_DEFAULT_SONNET_MODEL="$OPENROUTER_MODEL" | |
| export ANTHROPIC_DEFAULT_OPUS_MODEL="$OPENROUTER_MODEL" | |
| export API_TIMEOUT_MS=3000000 | |
| # ---- RUN CLAUDE ---- | |
| echo "⚡ Running Claude Code with OpenRouter config..." | |
| echo "Base URL: $ANTHROPIC_BASE_URL" | |
| echo "Model Haiku: $ANTHROPIC_DEFAULT_HAIKU_MODEL | Model Sonnet: $ANTHROPIC_DEFAULT_SONNET_MODEL | Model Opus: $ANTHROPIC_DEFAULT_OPUS_MODEL" | |
| echo | |
| # Pass along any args | |
| claude --dangerously-skip-permissions "$@" |
Save this script somewhere in your $PATH, e.g.:
vi ~/bin/or_claude
chmod +x ~/bin/or_claudeReplace your_openrouter_api_key_here with your real key (or export OPENROUTER_API_KEY before running).
or_claude