Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Proxy Docker Image

This repository contains a Docker Compose setup for running the claude-code-proxy service, built from the caffeinum:fix/gpt5-max-completion-tokens pull request.

What is this?

Claude Code Proxy is a service that translates Claude API requests to OpenAI-compatible API calls. This allows you to use OpenAI models (or any OpenAI-compatible API) as a backend for applications that expect the Claude API format.

Why this repo?

This docker build incorporates PR #35 which fixes issues with gpt5-max-completion-tokens, ensuring better compatibility with newer OpenAI models and their token limits.

Prerequisites

  • Docker and Docker Compose installed
  • An OpenAI API key (or compatible API service)

Quick Start

  1. Clone this repository:
git clone <your-repo-url>
cd claude-proxy
  1. Copy the example environment file and configure it:
cp .env.example .env
  1. Edit .env and set your API keys:
# Required
OPENAI_API_KEY="sk-your-openai-api-key-here"

# Optional but recommended for security
ANTHROPIC_API_KEY="your-expected-anthropic-api-key"
  1. Start the proxy:
docker compose up -d
  1. The proxy will be available at http://localhost:8082

Configuration

Required Settings

  • OPENAI_API_KEY: Your OpenAI API key (or compatible service key)

Optional Settings

Authentication

  • ANTHROPIC_API_KEY: If set, clients must provide this exact key to access the proxy

Server Settings

Check original repo : https://github.com/fuergaosi233/claude-code-proxy/blob/main/README.md

Model Mapping

The proxy maps Claude model requests to your configured models:

Claude Request Mapped To Environment Variable
Models with "haiku" SMALL_MODEL Default: gpt-4o-mini
Models with "sonnet" MIDDLE_MODEL Default: BIG_MODEL
Models with "opus" BIG_MODEL Default: gpt-4o

Provider Examples

OpenAI

OPENAI_API_KEY="sk-your-openai-key"
OPENAI_BASE_URL="https://api.openai.com/v1"
BIG_MODEL="gpt-5.2"
MIDDLE_MODEL="gpt-5.2"
SMALL_MODEL="gpt-5-mini"

Azure OpenAI:

OPENAI_API_KEY="your-azure-api-key"
OPENAI_BASE_URL="https://<your-microsoft-foundry-resource>.services.ai.azure.com/models"
BIG_MODEL="gpt-5.2"
MIDDLE_MODEL="gpt-5.2"
SMALL_MODEL="gpt-5-mini"

Local Models (Ollama):

OPENAI_API_KEY="dummy-key"
OPENAI_BASE_URL="http://localhost:11434/v1"
BIG_MODEL="llama3.1:70b"
MIDDLE_MODEL="llama3.1:70b"
SMALL_MODEL="llama3.1:8b"

Check

Point your Claude-compatible client to the proxy:

# Example with curl
curl http://localhost:8082/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-anthropic-api-key" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, world"}
    ]
  }'

Docker Image

This setup uses the pre-built image: freemanpolys/claude-code-proxy:latest

The image was built from PR #35 to include the max completion tokens fix.

Integration with Claude Code

This proxy is designed to work seamlessly with Claude Code CLI:

# Start the proxy
docker compose up -d

# Use Claude Code with the proxy
ANTHROPIC_BASE_URL=http://localhost:8082 ANTHROPIC_API_KEY="your-expected-anthropic-api-key" claude

# Or set permanently
export ANTHROPIC_BASE_URL=http://localhost:8082
claude
export ANTHROPIC_API_KEY=your-expected-anthropic-api-key

Troubleshooting

Connection Issues

  • Ensure the port 8082 is not already in use
  • Check if Docker container is running: docker compose ps
  • View logs for errors: docker compose logs

Authentication Errors

  • Verify your OpenAI API key is valid
  • If using ANTHROPIC_API_KEY, ensure clients are sending the correct key

Credits

License

This follows the license of the original claude-code-proxy project.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors