- Centralized authentication - Single point for API key management
- Usage tracking - Monitor usage across teams and projects
- Cost controls - Implement budgets and rate limits
- Audit logging - Track all model interactions for compliance
- Model routing - Switch between providers without code changes
LiteLLM configuration
LiteLLM is a third-party proxy service. Anthropic doesn’t endorse, maintain, or audit LiteLLM’s security or functionality. This guide is provided for informational purposes and may become outdated. Use at your own discretion.
Prerequisites
- Claude Code updated to the latest version
- LiteLLM Proxy Server deployed and accessible
- Access to Claude models through your chosen provider
Basic LiteLLM setup
Configure Claude Code:Authentication methods
Static API key
Simplest method using a fixed API key:Authorization header.
Dynamic API key with helper
For rotating keys or per-user authentication:- Create an API key helper script:
- Configure Claude Code settings to use the helper:
- Set token refresh interval:
Authorization and X-Api-Key headers. The apiKeyHelper has lower precedence than ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY.
Unified endpoint (recommended)
Using LiteLLM’s Anthropic format endpoint:- Load balancing
- Fallbacks
- Consistent support for cost tracking and end-user tracking