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.
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.
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.
- Docker and Docker Compose installed
- An OpenAI API key (or compatible API service)
- Clone this repository:
git clone <your-repo-url>
cd claude-proxy- Copy the example environment file and configure it:
cp .env.example .env- Edit
.envand 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"- Start the proxy:
docker compose up -d- The proxy will be available at
http://localhost:8082
OPENAI_API_KEY: Your OpenAI API key (or compatible service key)
ANTHROPIC_API_KEY: If set, clients must provide this exact key to access the proxy
Check original repo : https://github.com/fuergaosi233/claude-code-proxy/blob/main/README.md
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 |
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"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"}
]
}'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.
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- 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
- Verify your OpenAI API key is valid
- If using
ANTHROPIC_API_KEY, ensure clients are sending the correct key
- Original project: fuergaosi233/claude-code-proxy
- Fix PR: #35 by caffeinum
This follows the license of the original claude-code-proxy project.