Skip to content

ATC-O48/Claude-OpenAI-Code.

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude-OpenAI Bridge

OpenAI-compatible API interface for Anthropic's Claude models

License: BSL-1.0 Python Node.js Claude API

A proxy-adapter system that provides an OpenAI-compatible API for Anthropic's Claude models. Use Claude intelligence within existing OpenAI-based tooling and infrastructure — without rewriting your code.

How It Works · Quick Start · API Reference · Configuration


Architecture

graph LR
    subgraph Client["Client Applications"]
        A[OpenAI SDK]
        B[ChatGPT Plugins]
        C[Custom Apps]
    end

    subgraph Bridge["Claude-OpenAI Bridge"]
        D[Request Interceptor]
        E[Payload Transformer]
        F[Response Mapper]
    end

    subgraph Anthropic["Anthropic API"]
        G[Claude Models]
    end

    A --> D
    B --> D
    C --> D
    D --> E
    E -->|Claude API Format| G
    G -->|Claude Response| F
    F -->|OpenAI Format| A
    F --> B
    F --> C
Loading

How It Works

The bridge operates as a transparent translation layer between OpenAI-compatible clients and Anthropic's Claude API.

sequenceDiagram
    participant Client as Client (OpenAI SDK)
    participant Proxy as Claude-OpenAI Bridge
    participant Claude as Anthropic Claude API

    Client->>Proxy: POST /v1/chat/completions
    Note over Proxy: Intercept OpenAI request
    Proxy->>Proxy: Transform payload to Claude format
    Proxy->>Claude: POST /v1/messages
    Claude-->>Proxy: Claude response
    Proxy->>Proxy: Map response to OpenAI format
    Proxy-->>Client: OpenAI-compatible response
Loading

Translation Pipeline

Step Description
1. Intercept Receives standard OpenAI API requests (/v1/chat/completions, /v1/models, etc.)
2. Transform Converts OpenAI request schema to Anthropic Claude message format
3. Forward Sends transformed request to Claude API
4. Map Converts Claude response back to OpenAI-compatible response format

Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/ATC-O48/Claude-OpenAI-Code..git
cd Claude-OpenAI-Code.

# For Node.js/TypeScript
npm install

# For Python
pip install -r requirements.txt

Running the Bridge

# Set your Anthropic API key
export ANTHROPIC_API_KEY="your-api-key-here"

# Start the proxy server
./upload-all.sh

API Reference

Endpoints

Endpoint Method Description
/v1/chat/completions POST Chat completions (maps to Claude Messages API)
/v1/models GET List available models
/v1/health GET Service health check

Chat Completions

POST /v1/chat/completions

Accepts standard OpenAI chat completion requests and translates them to Claude API calls.


Examples

cURL

curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [
      {"role": "user", "content": "Hello, how are you?"}
    ],
    "max_tokens": 1024
  }'

Node.js (OpenAI SDK)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ANTHROPIC_API_KEY,
  baseURL: "http://localhost:3000/v1",
});

const response = await client.chat.completions.create({
  model: "claude-sonnet-4-20250514",
  messages: [{ role: "user", content: "Explain quantum computing" }],
  max_tokens: 1024,
});

console.log(response.choices[0].message.content);

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="your-anthropic-api-key",
    base_url="http://localhost:3000/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Write a haiku about coding"}],
    max_tokens=1024,
)

print(response.choices[0].message.content)

Configuration

Environment Variables

Variable Required Description
ANTHROPIC_API_KEY Yes Your Anthropic API key
PORT No Server port (default: 3000)
LOG_LEVEL No Logging level: debug, info, warn, error

Supported Models

Claude Model OpenAI Mapping Description
claude-opus-4-20250514 claude-opus-4-20250514 Most capable model for complex tasks
claude-sonnet-4-20250514 claude-sonnet-4-20250514 Balanced performance and speed
claude-haiku-3-5-20241022 claude-haiku-3-5-20241022 Fastest model for simple tasks

Key Features

Claude-OpenAI Bridge Transparent translation layer between OpenAI and Anthropic API protocols
Agent AI Autonomous agent logic for planning and tool usage via LLMs
Proxy-Adapter Pattern Clean architecture for intercepting and transforming API payloads
Multi-runtime Support Native implementations for both Python and Node.js environments
Apple Integration Support for Xcode, Swift Package Manager, CocoaPods, and Fastlane

Roadmap

  • Streaming response support
  • Function calling / tool use translation
  • Rate limiting and request queuing
  • Response caching layer
  • Docker deployment support
  • OpenAPI specification
  • SDK wrappers for common languages
  • Metrics and monitoring dashboard

Contributing

Contributions are welcome! Please read our Contributing Guide for details on development setup, code style, and the PR process.

# Fork and clone
git clone https://github.com/<your-username>/Claude-OpenAI-Code..git
cd Claude-OpenAI-Code.

# Create a feature branch
git checkout -b feature/your-feature-name

# Make changes, test, commit and push
git commit -m "feat: your feature description"
git push origin feature/your-feature-name

Then open a pull request against main.


License

This project is licensed under the Boost Software License 1.0.


Contact


About

Agent

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%