explaingit

jesuspeterson342-dot/anthropic-openai-proxy

Analysis updated 2026-05-18

2PythonAudience · developerComplexity · 2/5LicenseSetup · moderate

TLDR

A Python proxy server that translates Anthropic API requests into OpenAI format, letting Claude Code run against any OpenAI-compatible backend including local Ollama or OpenRouter.

Mindmap

mindmap
  root((anthropic-openai-proxy))
    What it does
      Translate Anthropic to OpenAI
      Correct SSE streaming
      Map model names
    Key components
      FastAPI server
      Request converter
      Streaming state machine
    Use cases
      Local Ollama backend
      OpenRouter gateway
      Self-hosted proxy
    Setup
      Copy .env config
      Set upstream API key
      Point Claude Code at port
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run Claude Code against a local Ollama or LM Studio model to avoid paying for the Anthropic API.

USE CASE 2

Route Claude Code traffic through OpenRouter to access many AI providers with a single API key.

USE CASE 3

Self-host a proxy so your team's AI requests never leave your own infrastructure.

USE CASE 4

Test Anthropic SDK code against different models without changing any client-side code.

What is it built with?

PythonFastAPISSEPydanticuvicorn

How does it compare?

jesuspeterson342-dot/anthropic-openai-proxy0-bingwu-0/live-interpreter0xkaz/llm-governance-dashboard
Stars222
LanguagePythonPythonPython
Setup difficultymoderatemoderatehard
Complexity2/52/54/5
Audiencedevelopergeneralops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires an API key for your chosen upstream OpenAI-compatible service such as OpenRouter or a local Ollama instance.

Use freely for any purpose including commercial projects, as long as you keep the copyright notice.

In plain English

This project is a small Python web server that acts as a translator between two AI service formats. On one side it speaks the language that Claude Code and Anthropic's software tools expect (called the Anthropic Messages API). On the other side, it forwards those requests to any service that speaks the more widely supported OpenAI Chat Completions format, including local models running on your own computer via Ollama or LM Studio, or cloud gateways like OpenRouter. The core problem it solves is that Claude Code is built to talk exclusively to Anthropic's API format. If you want to run Claude Code against a cheaper or self-hosted model, there is no built-in way to do that. Generic bridge tools exist but tend to fail on the precise streaming event sequence and tool-calling behavior that Claude Code relies on. This proxy is specifically built to handle those edge cases correctly: it runs a state machine that emits streaming events in the exact order the Anthropic SDK expects, and it correctly buffers and reassembles the fragments that carry tool call data. The project covers several details that simpler shims miss. It answers the token-counting endpoint that the Anthropic SDK calls before sending messages, because many proxies return an error here and cause the client to fail before making a single request. It also maps model names by substring rather than exact match, so names like "claude-sonnet-4-8" route to whatever upstream model you configure for Sonnet. Error responses are translated into the format Anthropic clients understand, rather than passing through raw error shapes. The upstream API key is stored in a local configuration file rather than passed by the client, keeping the key private. Setup involves cloning the repo, copying a configuration file, setting your upstream API key and the base URL for whichever OpenAI-compatible backend you want to use, and running the server. Once it is running locally, you point Claude Code at it by changing one environment variable. The README includes separate instructions for Bash, Fish, Zsh, and PowerShell. The codebase is about five Python modules with no database dependency.

Copy-paste prompts

Prompt 1
Set up anthropic-openai-proxy to point Claude Code at my local Ollama instance. Show me the exact .env values and which environment variable to set in Claude Code.
Prompt 2
Explain how the streaming state machine in streaming.py works and why the exact SSE event order matters for Claude Code compatibility.
Prompt 3
Walk me through connecting anthropic-openai-proxy to OpenRouter so I can use GPT-4o through the Anthropic SDK.
Prompt 4
What does the count_tokens endpoint in main.py do and why do other proxies often break by skipping it?
Prompt 5
Show me how to add a fourth model tier (beyond big/middle/small) to the model mapping logic in converter.py.

Frequently asked questions

What is anthropic-openai-proxy?

A Python proxy server that translates Anthropic API requests into OpenAI format, letting Claude Code run against any OpenAI-compatible backend including local Ollama or OpenRouter.

What language is anthropic-openai-proxy written in?

Mainly Python. The stack also includes Python, FastAPI, SSE.

What license does anthropic-openai-proxy use?

Use freely for any purpose including commercial projects, as long as you keep the copyright notice.

How hard is anthropic-openai-proxy to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is anthropic-openai-proxy for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub jesuspeterson342-dot on gitmyhub

Verify against the repo before relying on details.