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.5.tar.gz (26.0 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.5-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ant2oai-0.1.5.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

Hashes for ant2oai-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7628d8b0fe191b8220152eb5ac78e7c14d264c7334bf4975a79a8198f2d6a676
MD5 b4a335e8385fb9f6391cab0bebfd120f
BLAKE2b-256 17c23b2387f2b2b5d05ddafcf42e1edc666051495361f0ae803525dc6b4c0b92

See more details on using hashes here.

Provenance

The following attestation bundles were made for ant2oai-0.1.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: ant2oai-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 19.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5633c5be9c386336de738101f9aca798c5a740c3b598c53b1732e357ee540b4f
MD5 39e5128fec8f5f472f93b83c6ad470fe
BLAKE2b-256 4535d4f6d8efc2a38f2407db9adabb2cb10152ee47f455e09b3deddaf33ee508

See more details on using hashes here.

Provenance

The following attestation bundles were made for ant2oai-0.1.5-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