An Anthropic-compatible local proxy server designed to route Claude Code CLI requests to OpenCode Zen or any other OpenAI-compatible chat completions backend (e.g., DeepSeek, OpenRouter, local Ollama).
This proxy allows you to run the feature-rich Claude Code CLI using alternative, affordable, or self-hosted models, fully supporting streaming, tool calling, and DeepSeek thinking/reasoning blocks.
- Protocol Translation: Seamlessly converts Anthropic messages API payloads (input schemas, messages, system prompts) to OpenAI-compatible Chat Completions requests.
- Bi-Directional Tool Calling: Automatically translates tool definition schemas, tool invocations, and tool results between Anthropic and OpenAI formats.
- SSE Stream Relaying: Converts upstream OpenAI chunk streams into Anthropic-compatible Server-Sent Event (SSE) streams in real-time.
- DeepSeek Reasoning Blocks: Maps reasoning and thinking outputs (
reasoning_content) directly to Anthropic's<thinking>format, preserving the internal reasoning steps of reasoning models. - Local Logs Dashboard: Provides a lightweight endpoint (
/logs) to trace proxy requests and performance.
- Node.js: Version 18 or higher.
- Claude Code CLI: Installed globally via npm:
npm install -g @anthropic-ai/claude-code
Navigate to the directory and install dependencies:
npm installCopy the template configuration file:
copy .env.zen.example .env.zen(On macOS/Linux, run: cp .env.zen.example .env.zen)
Open .env.zen in your editor and configure the keys:
UPSTREAM_API_KEY=your_actual_upstream_api_key_here
UPSTREAM_MODEL=deepseek-v4-flash-free
UPSTREAM_CHAT_COMPLETIONS_URL=https://opencode.ai/zen/v1/chat/completionsLaunch the proxy:
npm startThe server will start by default at http://127.0.0.1:4040.
To redirect the Claude Code CLI to use your local proxy, you must run it with specific environment variables set.
set ANTHROPIC_BASE_URL=http://127.0.0.1:4040
set ANTHROPIC_API_KEY=claude-zen-local-key
set ANTHROPIC_MODEL=claude-code-proxy
set ENABLE_TOOL_SEARCH=true
claude$env:ANTHROPIC_BASE_URL="http://127.0.0.1:4040"
$env:ANTHROPIC_API_KEY="claude-zen-local-key"
$env:ANTHROPIC_MODEL="claude-code-proxy"
$env:ENABLE_TOOL_SEARCH="true"
claudeexport ANTHROPIC_BASE_URL="http://127.0.0.1:4040"
export ANTHROPIC_API_KEY="claude-zen-local-key"
export ANTHROPIC_MODEL="claude-code-proxy"
export ENABLE_TOOL_SEARCH="true"
claudeTo resume your previous Claude session while pointing to the proxy, add the -r flag:
claude -rThe following environment variables can be customized in .env.zen:
| Variable | Description | Default |
|---|---|---|
UPSTREAM_API_KEY |
The API Key for your upstream provider. | Required |
UPSTREAM_MODEL |
The model name passed to the upstream completions API. | deepseek-v4-flash-free |
UPSTREAM_CHAT_COMPLETIONS_URL |
Endpoint of the upstream completions API. | https://opencode.ai/zen/v1/chat/completions |
ANTHROPIC_MODEL_ALIAS |
The name of the model alias Claude Code will request. | claude-code-proxy |
PROXY_API_KEY |
Key needed to authorize requests made to the proxy. | claude-zen-local-key |
DEEPSEEK_THINKING_TYPE |
Controls whether DeepSeek thinking is enabled or disabled. |
enabled |
UPSTREAM_REASONING_EFFORT |
Reasoning effort level (none, low, medium, high, xhigh). |
xhigh |
HOST |
Network interface to bind the proxy server to. | 127.0.0.1 |
PORT |
Local port for the proxy server. | 4040 |
You can inspect the API requests forwarded through the proxy by navigating to:
http://127.0.0.1:4040/logs
This endpoint displays a JSON payload listing recent completions traffic, processing metadata, and stream states.