Skip to content

About

OpenAI-compatible API proxy for Anthropic Claude

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

clauderouter

OpenAI-compatible API proxy for Anthropic Claude — use Claude with any OpenAI SDK, tool, or application. Zero config, zero dependencies, drop-in replacement.

clauderouter translates OpenAI chat completion requests into Anthropic Claude API calls. Point your existing OpenAI-based code at clauderouter and start using Claude without changing a single line.

Features

  • OpenAI API compatibility — works with the OpenAI Python SDK, Node.js SDK, and any OpenAI-compatible client
  • Streaming support — full SSE streaming, translated in real time
  • Automatic model mapping — send gpt-4o and it routes to claude-sonnet-4-6
  • Dual authentication — supports both Anthropic API keys and OAuth tokens
  • Zero dependencies — built with Go standard library only
  • CORS enabled — use directly from browsers and frontends

Quick Start

# Build
go build -o clauderouter ./cmd/clauderouter

# Run
export ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
./clauderouter

The server starts on :8080 by default. Your OpenAI-compatible endpoint is http://localhost:8080/v1/chat/completions.

Usage

curl

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": false
  }'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8080/v1",
    api_key="unused",  # not validated by clauderouter
)

response = client.chat.completions.create(
    model="gpt-4o",  # routes to claude-sonnet-4-6
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Node.js (OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:8080/v1",
  apiKey: "unused",
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

for await (const chunk of response) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}

Model Mapping

Send OpenAI model names or Claude model names — clauderouter resolves them automatically.

OpenAI Model Claude Model
gpt-4 claude-sonnet-4-6
gpt-4o claude-sonnet-4-6
gpt-4o-mini claude-haiku-4-5-20251001
gpt-3.5-turbo claude-haiku-4-5-20251001

Claude aliases also work:

Alias Resolves To
claude-sonnet claude-sonnet-4-6
claude-opus claude-opus-4-6
claude-haiku claude-haiku-4-5-20251001
claude-3.5-sonnet claude-3-5-sonnet-20241022

Any model starting with claude- that isn't in the map is passed through directly. Unknown models default to claude-sonnet-4-6.

API Endpoints

Method Path Description
POST /v1/chat/completions Chat completions (OpenAI-compatible)
POST /chat/completions Chat completions (alternate path)
GET /v1/models List available models
GET /models List models (alternate path)
GET /health Health check

Configuration

Flag Env Var Default Description
-api-key ANTHROPIC_API_KEY — Anthropic API key or OAuth token
-addr — :8080 Listen address
-api-url — Anthropic default Override Anthropic API URL

Authentication

clauderouter supports both Anthropic authentication methods:

  • API Keys (sk-ant-api03-...) — sent as x-api-key header
  • OAuth Tokens (sk-ant-oat01-...) — sent as Bearer token in Authorization header

License

MIT

About

OpenAI-compatible API proxy for Anthropic Claude

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages