litellm proxy now supports Anthropic API Proxy for any LLM via LiteLLM. docs
uv tool install 'litellm[proxy]'
# or
pipx install 'litellm[proxy]'
# or
pip install 'litellm[proxy]'cat <<\EOF >config.yaml
model_list:
- model_name: "*"
litellm_params:
model: "*"
EOF
litellm --config config.yamlexport ANTHROPIC_BASE_URL=http://localhost:4000
claude --model gemini/gemini-2.5-pro
# or
export ANTHROPIC_MODEL=gemini/gemini-2.5-pro
export ANTHROPIC_SMALL_FAST_MODEL=gemini/gemini-2.5-flash
claudeUse Anthropic clients (like Claude Code) with any LLM backend. 🤝
A proxy server that lets you use Anthropic clients with any LLM provider supported by LiteLLM. 🌉
- Universal LLM Support: Expanded from only supporting OpenAI and Gemini to supporting any LLM provider compatible with LiteLLM.
- Reliable Tool Calling: Replaced manual, text handling based tool call handling with OpenAI format based LiteLLM's robust, native translation. This improves the reliability and consistency of tool usage across all models.
- Fixed thinking budget issues: The proxy now correctly handles the
thinking_budgetparameter which is enabled bythink hard,ultrathink, etc. - Easy Installation and Execution: Packaged for easy installation via
pip,pipx, oruv, and can be run directly with theclaude-proxycommand, eliminating the need for manual cloning and setup. - Simplified Configuration: Replaced the complex
.envfile with straightforward environment variables (BIG_MODEL,SMALL_MODEL) for easier setup. - Improved Code Quality: The codebase has been refactored for clarity and maintainability, with
pre-commithooks integrated to ensure consistent code standards.
- An API key for your chosen LLM provider (e.g., OpenAI, Google, Anthropic, Cohere, etc.) 🔑
Install the proxy server using one of the following methods:
uv tool install 'git+https://github.com/ryul99/claude-code-proxy.git'
# or
pipx install 'git+https://github.com/ryul99/claude-code-proxy.git'
# or
pip install 'git+https://github.com/ryul99/claude-code-proxy.git'And run the proxy server:
BIG_MODEL=openai/gpt-4.1 SMALL_MODEL=openai/gpt-4.1 claude-proxyThat's it! The proxy server will start listening on port 8082 by default. You can change the port by setting --port option
-
Install Claude Code (if you haven't already):
npm install -g @anthropic-ai/claude-code
-
Connect to your proxy:
ANTHROPIC_BASE_URL=http://localhost:8082 claude
-
That's it! Your Claude Code client will now use the configured backend models through the proxy. 🎯
The proxy maps Anthropic's sonnet and haiku models to any LiteLLM-supported model string specified in your environment variables.
Claude Sonnet->BIG_MODELClaude Haiku->SMALL_MODEL
You must use the correct model identifier as required by LiteLLM, which typically includes the provider prefix (e.g., openai/, gemini/, anthropic/).
Control the mapping by setting the environment variables
Example 1: Use OpenAI
export OPENAI_API_KEY="your-openai-key"
BIG_MODEL="openai/gpt-4o" SMALL_MODEL="openai/gpt-4o-mini" claude-proxyExample 2: Use Google Models
export GEMINI_API_KEY="your-google-key"
BIG_MODEL="gemini/gemini-2.5-pro" SMALL_MODEL="gemini/gemini-2.5-flash" claude-proxyExample 3: Use Anthropic Models
export ANTHROPIC_API_KEY="your-anthropic-key"
BIG_MODEL="anthropic/claude-sonnet-4-20250514" SMALL_MODEL="anthropic/claude-3-haiku-20240307"API keys for the respective providers must be set in your environment variables. The proxy will automatically use these keys to authenticate requests to the LLM provider.
This means you can use different providers for BIG_MODEL and SMALL_MODEL if desired, allowing for flexible configurations based on your needs.
For more supported models and provider-specific environment variables (like AZURE_API_BASE, etc.), refer to the LiteLLM documentation.
This proxy works by:
- Receiving requests in Anthropic's API format 📥
- Translating the requests to a generic format via LiteLLM 🔄
- Sending the translated request to your configured LLM provider 📤
- Converting the response back to Anthropic format 🔄
- Returning the formatted response to the client ✅
The proxy handles both streaming and non-streaming responses, maintaining compatibility with all Claude clients. 🌊
Contributions are welcome! Please feel free to submit a Pull Request. 🎁
This project uses pre-commit hooks to ensure code quality. To set up pre-commit hooks, run:
pip install pre-commit
pre-commit installThis will automatically run linting and formatting checks before each commit.