Skip to main content

Lightweight Anthropic-to-OpenAI API proxy — run Claude Code with any OpenAI-compatible backend

Project description

a2o

PyPI version Python CI License: MIT

Lightweight Anthropic-to-OpenAI API proxy. Run Claude Code with any OpenAI-compatible backend.

Features

  • Translates Anthropic /v1/messages requests to OpenAI /v1/chat/completions format
  • 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)
  1. Claude Code sends requests in Anthropic format to the proxy
  2. The proxy converts requests to OpenAI chat completion format
  3. The upstream response is converted back to Anthropic format
  4. 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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ant2oai-0.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ant2oai-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file ant2oai-0.1.0.tar.gz.

File metadata

  • Download URL: ant2oai-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ant2oai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 13b463eff113550a64e6b5e30276f00c647437a7f423bce2e916ce641b12fe44
MD5 a5af60ef1d8f580aba520d260fb6d63a
BLAKE2b-256 3e09458822f50da20672522a5657baf9da58346ef181a1af4d71bfc3c68967bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for ant2oai-0.1.0.tar.gz:

Publisher: publish.yml on WqyJh/a2o

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ant2oai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ant2oai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ant2oai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 595f2c48abc08346fd93966cf3279f12c9277712e4f12911b79c63a5b3a34bc2
MD5 fc9600e6afa95c1515e372f6271948aa
BLAKE2b-256 7fc2a86ea971fe08608cad0be0d58ba9ff65f4b5a62c0cb3807718248ea4ecf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ant2oai-0.1.0-py3-none-any.whl:

Publisher: publish.yml on WqyJh/a2o

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page