Local proxy router for AI API requests. Intercepts OpenAI-compatible calls from CLI tools and routes to DeepSeek, Claude, or OpenAI based on environment variables.
cd ai-proxy
pip install -e .# Route all requests to DeepSeek (default)
export DEEPSEEK_API_KEY=sk-your-key
ai-proxy
# Route to Claude
export ANTHROPIC_API_KEY=sk-ant-your-key
ai-proxy --target claude
# Or via env var
export AI_PROXY_TARGET=claude
ai-proxyPoint your CLI tools at http://localhost:11434/v1:
export OPENAI_API_KEY=sk-proxy-placeholder-value
export OPENAI_BASE_URL=http://localhost:11434/v1| Env var | Default | Description |
|---|---|---|
AI_PROXY_TARGET |
deepseek |
Provider: deepseek, claude, or openai |
AI_PROXY_PORT |
11434 |
Listen port |
AI_PROXY_HOST |
127.0.0.1 |
Bind address |
AI_PROXY_MAP |
— | Model name mappings: gpt-4->claude-sonnet-5,gpt-3.5->deepseek-chat |
DEEPSEEK_API_KEY |
— | DeepSeek API key |
ANTHROPIC_API_KEY |
— | Anthropic API key |
OPENAI_API_KEY |
— | OpenAI API key |
Map model names that tools send to provider-native models:
export AI_PROXY_MAP="gpt-4->claude-sonnet-5-20251001,gpt-3.5-turbo->deepseek-chat"| Path | Method | Description |
|---|---|---|
/health |
GET | Health check |
/v1/models |
GET | List models |
/v1/chat/completions |
POST | Chat completions (streaming + non-streaming) |
OpenAI-compatible passthrough. Sets DEEPSEEK_API_KEY. Base URL: https://api.deepseek.com.
Full OpenAI ↔ Anthropic format translation. Handles:
- System message extraction and merging
- Content block conversion (text, images, tool use, tool results)
- Tool/function definition translation
- Streaming SSE event conversion
- Model name aliasing (
claude-sonnet-5→claude-sonnet-5-20251001)
Direct passthrough with configurable base URL (OPENAI_BASE_URL).
CLI tool ──OpenAI─format──► ai-proxy (:11434) ──native──► Claude / DeepSeek / OpenAI
◄──OpenAI─format── ◄──native──
- Tool sends OpenAI-format request to
http://localhost:11434/v1/chat/completions - Proxy reads
AI_PROXY_TARGETto pick provider - If provider speaks different format (Claude), proxy translates
- Response translated back to OpenAI format
- Tool receives standard OpenAI response — doesn't know the difference
ai-proxy [--target deepseek|claude|openai] [--port 11434] [--host 127.0.0.1] [--verbose]