Lightweight Anthropic-to-OpenAI API proxy — run Claude Code with any OpenAI-compatible backend
Project description
a2o
Lightweight Anthropic-to-OpenAI API proxy. Run Claude Code with any OpenAI-compatible backend.
Features
- Translates Anthropic
/v1/messagesrequests to OpenAI/v1/chat/completionsformat - Streaming (SSE) and non-streaming support
- Tool calling (function calling) with full round-trip conversion
- Extended thinking / reasoning content
- Image content (base64 and URL)
- Multi-worker deployment with connection pooling
- Minimal dependencies: FastAPI + httpx
Installation
pip install ant2oai
Or with uv:
uv pip install ant2oai
Quick Start
Start the proxy pointing to any OpenAI-compatible endpoint:
a2o --upstream http://your-openai-endpoint/v1/chat/completions --model your-model
Then configure Claude Code to use the proxy:
export ANTHROPIC_BASE_URL=http://127.0.0.1:3578
export ANTHROPIC_API_KEY=any-string # passed through to upstream
claude
Usage
usage: a2o [-h] [--upstream UPSTREAM] [--model MODEL] [--host HOST]
[--port PORT] [--timeout TIMEOUT] [--debug]
[--workers WORKERS] [--max-connections MAX_CONNECTIONS]
[--max-connections-per-host MAX_CONNECTIONS_PER_HOST]
options:
--upstream UPSTREAM OpenAI-compatible base URL
--model MODEL Default model name override
--host HOST Bind host (default: 127.0.0.1)
--port PORT Bind port (default: 3578)
--timeout TIMEOUT Request timeout in seconds (default: 300)
--debug Enable debug logging
--workers WORKERS Number of worker processes (default: 1)
--max-connections N Max upstream connections (default: 1000)
--max-connections-per-host N
Max per-host connections (default: 500)
Production Deployment
For high-throughput scenarios:
a2o \
--upstream http://your-endpoint/v1/chat/completions \
--model your-model \
--host 0.0.0.0 \
--port 3578 \
--workers 4 \
--max-connections 2000
How It Works
Claude Code ──► a2o proxy ──► OpenAI-compatible backend
(Anthropic API) (converts) (OpenAI API)
- Claude Code sends requests in Anthropic format to the proxy
- The proxy converts requests to OpenAI chat completion format
- The upstream response is converted back to Anthropic format
- Claude Code receives a native-looking Anthropic response
Conversion Details
| Anthropic | OpenAI |
|---|---|
system (string/blocks) |
First system message |
messages[].content blocks |
messages[].content parts |
tool_use content blocks |
tool_calls on assistant messages |
tool_result content blocks |
tool role messages |
thinking blocks |
reasoning_content field |
max_tokens |
max_tokens |
stop_sequences |
stop |
| Streaming SSE events | Streaming SSE chunks |
Development
# Clone and install
git clone https://github.com/WqyJh/a2o.git
cd a2o
uv sync --all-extras
# Run tests
uv run pytest
# Lint
uv run ruff check .
uv run ruff format --check .
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ant2oai-0.1.3.tar.gz.
File metadata
- Download URL: ant2oai-0.1.3.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f7cee92d267c02a4271cd5e4bc16835c52f610f885eb048a31351eed91ec8f3
|
|
| MD5 |
10c3de7e0942780623199a9b504289c4
|
|
| BLAKE2b-256 |
445674b8d423c72bba53506e137c0c3f3c644535ee1ce8971ec43ad1a23137f8
|
Provenance
The following attestation bundles were made for ant2oai-0.1.3.tar.gz:
Publisher:
publish.yml on WqyJh/a2o
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ant2oai-0.1.3.tar.gz -
Subject digest:
7f7cee92d267c02a4271cd5e4bc16835c52f610f885eb048a31351eed91ec8f3 - Sigstore transparency entry: 1307840331
- Sigstore integration time:
-
Permalink:
WqyJh/a2o@e6edc30a4b533fe748fe6e219a3a7d7b124daae6 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/WqyJh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e6edc30a4b533fe748fe6e219a3a7d7b124daae6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ant2oai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ant2oai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d7594effeedcb8cd40fe4fd43e3d78c2e34a5ac84ac72d5db93b7d04b74e363
|
|
| MD5 |
63a10ab35287dbae7c3c8a1f1d43f615
|
|
| BLAKE2b-256 |
2364519eb4c8e559df5f71523983802d9213ccac281b72b9a11eadd5a18816af
|
Provenance
The following attestation bundles were made for ant2oai-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on WqyJh/a2o
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ant2oai-0.1.3-py3-none-any.whl -
Subject digest:
4d7594effeedcb8cd40fe4fd43e3d78c2e34a5ac84ac72d5db93b7d04b74e363 - Sigstore transparency entry: 1307840419
- Sigstore integration time:
-
Permalink:
WqyJh/a2o@e6edc30a4b533fe748fe6e219a3a7d7b124daae6 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/WqyJh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e6edc30a4b533fe748fe6e219a3a7d7b124daae6 -
Trigger Event:
release
-
Statement type: