Overview
Claude Adapter is a lightweight proxy that converts Anthropic Messages API requests to OpenAI Chat Completions format, enabling you to use OpenAI-compatible APIs (like GPT-4, Local LLMs via vLLM, etc.) with Claude Code.
Input (Claude)
POST /v1/messages
Output (OpenAI)
POST /v1/chat/completions
# Installation
Prerequisites: Node.js 20.0.0 or higher.
npm install -g claude-adapter
# Configuration
Run the tool for the first time to start the interactive configuration wizard.
claude-adapter
CLI Options
| Option | Description | Default |
|---|---|---|
| -p, --port | Port for proxy server | 3080 |
| -r, --reconfigure | Force reconfiguration | false |
Model Mapping
You can map Claude model names to specific OpenAI deployments.
- opus → gpt-5.2-codex
- sonnet → gpt-5.2-mini
- haiku → gpt-5.2-nano
# API Reference
You can use the adapter programmatically in your own Node.js applications.
import { createServer, AdapterConfig } from 'claude-adapter';
const config: AdapterConfig = {
baseUrl: 'https://api.openai.com/v1',
apiKey: process.env.OPENAI_API_KEY!,
models: {
opus: 'gpt-4-turbo',
sonnet: 'gpt-3.5-turbo'
}
};
const server = createServer(config);
await server.start(3080);
Troubleshooting
Port already in use
If port 3080 is taken, specify a custom port:
claude-adapter --port 3000
Claude Code not connecting
Verify ~/.claude/settings.json
contains:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:3080"
}
}