How 1rgs/claude-code-proxy works
This is a FastAPI proxy that accepts Anthropic Messages API requests and routes them to OpenAI, Gemini, or Anthropic through LiteLLM, translating request and response formats. Its principal workflow supports both streaming and non-streaming messages, including tool use; a separate endpoint handles token-count requests. The README documents provider selection, model mapping, and Vertex AI authentication. The excerpts show only parts of server.py, so internal helper wiring beyond the documented workflow is not detailed.
Main entry points: server.py Messages endpoint
Components 14
Anthropic API
- Messages endpoint
server.py - Token-count endpoint
server.py - Request schemas
server.py
Format Translation
- Request conversion
server.py - Tool conversion
server.py - Response conversion
server.py - Streaming events
server.py
Model Routing
- Model mapping
server.py - Provider configuration
server.py - LiteLLM
server.py
Other components
- Anthropic client
- OpenAI API
- Gemini / Vertex AI
- Anthropic API
Connections 14
- Anthropic client → Messages endpoint: sends messages
- Anthropic client → Token-count endpoint: counts tokens
- Messages endpoint → Request schemas: validates
- Messages endpoint → Model mapping: selects model
- Messages endpoint → Request conversion: converts request
- Request conversion → Tool conversion: converts tools
- Messages endpoint → LiteLLM: dispatches request
- Provider configuration → Model mapping: configures
- LiteLLM → OpenAI API: calls
- LiteLLM → Gemini / Vertex AI: calls
- LiteLLM → Anthropic API: calls
- Messages endpoint → Response conversion: converts response
- Messages endpoint → Streaming events: formats stream
- Token-count endpoint → Model mapping: checks model