Skip to main content

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

Reason this release was yanked:

bug

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.1.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.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ant2oai-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1b0987e83660d4e0ff09e4b23c757d321d949baaa5c7bb5c940afd8ddb8fa3d7
MD5 8adc0ffe5faf1313f5a277c912835113
BLAKE2b-256 fe74ef850fa8a86dc0fee5da48cc8c07e16410bc6d519a0b272a60396dae7041

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ant2oai-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0604208daf1d4465d1d3465dc5c3797ab78111b39854c9735ac8a27c013205
MD5 b631f59d96f2f87b8c294a7f8292db8d
BLAKE2b-256 da6d5ab7b83fe8e84e4afeefa13c7896866f97ccf15a189eca55a54d66609447

See more details on using hashes here.

Provenance

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