Skip to main content

Route Claude Code through OpenRouter to alternative models

Project description

claude-or

Route Claude Code through OpenRouter to alternative models. One command, zero config files.

Quick Start

1. Install

# From GitHub
pipx install 'claude-or @ git+https://github.com/iagochavarry/claude-or.git'

# Or with pip
pip install 'claude-or @ git+https://github.com/iagochavarry/claude-or.git'

2. Configure

Create a .env file (in your working directory or ~/.claude-or/.env):

OPENROUTER_API_KEY=sk-or-v1-your-key-here

3. Run

Full mode (proxy + Claude Code):

claude-or

Proxy only (start proxy in background):

claude-or --proxy-only
# Then in another terminal:
claude-or --claude-only

Claude only (connect to existing proxy):

claude-or --claude-only

Pass additional flags to Claude Code:

claude-or -- --debug --allowed-tools Bash,Read

Headless mode (single prompt, no TUI):

claude-or -- -p "Explain this codebase"

Quickly understand any codebase:

claude-or -- -p "Explain this codebase"

That's it. All Claude model requests are now routed through OpenRouter.

Configuration

All configuration is via environment variables or .env file:

Variable Default Description
OPENROUTER_API_KEY required Your OpenRouter API key
CLAUDE_SONNET_MODEL openrouter/moonshotai/kimi-k2.5 Backend for Sonnet requests
CLAUDE_OPUS_MODEL openrouter/moonshotai/kimi-k2.5 Backend for Opus requests
CLAUDE_HAIKU_MODEL openrouter/moonshotai/kimi-k2.5 Backend for Haiku requests
OPENROUTER_PROVIDER Together Provider pinning (empty = no pinning)
CLAUDE_OR_PORT 4000 Proxy port

CLI Flags

claude-or -p 4001           # custom port
claude-or -v                # verbose logging
claude-or --proxy-only      # proxy only, no Claude launch
claude-or --claude-only     # Claude only, connect to existing proxy
claude-or -- --debug        # pass --debug to Claude Code

How It Works

Claude Code sends requests to http://localhost:4000 thinking it's talking to Anthropic's API. The proxy (powered by LiteLLM) translates the request format and routes it to your configured model on OpenRouter.

Claude Code → localhost:4000 → LiteLLM Proxy → OpenRouter → Your Model

Why LiteLLM?

  • Translates between Anthropic message format and OpenAI chat format
  • drop_params silently discards Anthropic-specific fields that would cause errors
  • Provider pinning ensures consistent backend quality
  • Production-grade, actively maintained

.env File Lookup Order

  1. .env in current working directory
  2. ~/.claude-or/.env
  3. Shell environment variables

Shell env vars always take precedence over .env files.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_or-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_or-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file claude_or-0.1.0.tar.gz.

File metadata

  • Download URL: claude_or-0.1.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for claude_or-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0cfd4eec7bef1f101d8d227e4680614c006d655368a52a7945dc8c7f4940c3f
MD5 0cb0336bee9e8ac54560b27b3d46a9a7
BLAKE2b-256 e5dc16e4553890024cc566157f2a60b62a539e92d7f54b6b3a17d77c5be07a3f

See more details on using hashes here.

File details

Details for the file claude_or-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: claude_or-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for claude_or-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c1409d1c68f228a76bbfb5495a91b26c04774e515c46300b5aeb58da37d1380
MD5 813506188f99b2b83f4b5c1da5996926
BLAKE2b-256 ee0a6bc6e55f2ef84bf87eb52a5ecbbdf4e533a2953f5f25060b33756ea928e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page