anthroproxy
v1.0.3
Published
Protocol translation proxy: Anthropic Messages API <-> OpenAI Chat Completions API
Maintainers
Readme
anthroproxy
Protocol translation proxy: accepts Anthropic Messages API format and forwards to any OpenAI-compatible endpoint.
Use it to make tools that only speak Anthropic's API (like Claude Code) work with OpenAI-compatible backends (OpenAI, DeepSeek, Ollama, vLLM, etc.).
Quick start
npx anthroproxy \
--target-url https://api.openai.com/v1 \
--api-key sk-xxxx \
--port 8080Or with a .env file:
echo "TARGET_URL=https://api.openai.com/v1
TARGET_API_KEY=sk-xxxx" > .env
npx anthroproxyUsage with Claude Code
claude config set proxy http://localhost:8080Now Claude Code sends requests to the proxy, which translates and forwards them to your target backend.
Options
CLI flags
| Flag | Default | Description |
|---|---|---|
| --port <n> | 8080 | Port to listen on |
| --target-url <url> | https://api.openai.com/v1 | Upstream API base URL |
| --api-key <key> | — | API key for the upstream |
| --model-mapping <str> | — | Model mapping, e.g. claude-3:gpt-4o,claude-4:gpt-4-turbo |
| --default-model <name> | gpt-5 | Fallback model if no mapping matches |
| --log-level <level> | DEBUG | One of: DEBUG, INFO, WARN, ERROR, NONE |
| --help | — | Show help message |
| --version | — | Show version number |
Environment variables
All CLI flags have matching environment variables:
| Variable | Corresponding flag |
|---|---|
| PORT | --port |
| TARGET_URL | --target-url |
| TARGET_API_KEY | --api-key |
| MODEL_MAPPING | --model-mapping |
| DEFAULT_MODEL | --default-model |
| LOG_LEVEL | --log-level |
Model mapping
When the incoming request uses an Anthropic model name, the proxy maps it to a target model. Without a mapping, it falls back to --default-model.
--model-mapping "claude-sonnet-4-20250514:gpt-4o,claude-opus-4:gpt-4-turbo"Endpoints
| Path | Description |
|---|---|
| POST /v1/messages | Translate and forward Anthropic → OpenAI request |
| GET /health | Health check (returns {"status":"ok","uptime":...}) |
Features
- Streaming & non-streaming — Full SSE event translation
- Extended thinking — Native
thinkingcontent block support - Tool use — Bidirectional
tool_use↔function callingconversion - Image input — Anthropic
imageblocks → OpenAIimage_url - Reasoning fallback — Automatic retry without
reasoning_contentif upstream doesn't support it
License
MIT
