Files
ein-ai-proxy/README.md
T
harrison 7fc0bafb01 Initial commit: ein-ai-proxy
Anthropic-compatible API proxy that routes requests to multiple
providers (Anthropic, Z.ai/GLM-4.7, DeepSeek V3.2) based on
model name. Zero dependencies, SSE streaming, bearer token auth.

Designed to run behind Caddy/nginx on a home server, enabling
Claude Code and Roo Code clients to connect from anywhere.
2026-03-26 13:54:22 -05:00

2.2 KiB

ein-ai-proxy

Anthropic-compatible API proxy that routes requests to multiple AI providers based on model name. Built to run on a home server behind nginx, letting you use Claude Code and Roo Code from any machine while keeping costs optimized.

How it works

Clients (Claude Code CLI, Roo Code, Cline, etc.) send standard Anthropic Messages API requests to your proxy. The proxy inspects the model field and forwards the request to the appropriate provider:

Client requests Routed to Why
claude-opus-4-6 Anthropic API Complex tasks that need the best model
claude-sonnet-4-6 Z.ai → GLM-4.7 Daily workhorse, $10/mo flat rate
claude-haiku-4-5-* DeepSeek → V3.2 Trivial tasks, pennies per token
glm-4.7 (direct) Z.ai Explicit GLM request
deepseek-chat (direct) DeepSeek Explicit DeepSeek request

SSE streaming is fully supported — responses are piped through without buffering.

Setup

# 1. Copy and edit config
cp config.example.json config.json
nano config.json  # Add your API keys + set authToken

# 2. Deploy (installs systemd service, tests proxy)
chmod +x deploy.sh
./deploy.sh

# 3. Follow the nginx + SSL steps printed by deploy.sh

Client Configuration

Claude Code CLI

Add to ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.maybe.zone",
    "ANTHROPIC_AUTH_TOKEN": "your-proxy-auth-token",
    "API_TIMEOUT_MS": "3000000"
  }
}

Roo Code (VS Code)

  1. Open Roo Code settings
  2. Set API Provider to Anthropic
  3. Enter your proxy auth token as the API Key
  4. Check Use custom base URL
  5. Enter https://ai.maybe.zone

Switching models

From Claude Code, the default Sonnet model routes to GLM-4.7. To use Opus for a complex task, use /model and select Opus — the proxy will route it to the real Anthropic API.

Files

  • proxy.mjs — The proxy server (zero dependencies, Node.js 18+)
  • config.json — Your API keys and auth token (gitignored)
  • config.example.json — Template config
  • ein-ai-proxy.service — Systemd unit file
  • nginx-ai-proxy.conf — Nginx reverse proxy config
  • deploy.sh — Deployment script

License

MIT