Files
ein-ai-proxy/README.md
T
William Stuckey 3cfc7cffeb Add persistent context files and cleanup stale references
- Add CONTEXT.md: Full infrastructure documentation with architecture diagram,
  routing table, network details, common operations, and important limitations
- Add CLAUDE.md: Project-level context for AI agents working in this codebase
- Add global-claude-md/CLAUDE.md: User-level global context for ~/.claude/
- Delete nginx-ai-proxy.conf: Unused, Caddy replaced nginx on big-server
- Update deploy.sh: Remove stale nginx setup step, update domain to ai.ein-softworks.com
- Update README.md: Remove nginx-ai-proxy.conf from files list, update domain,
  and remove leaked auth token from example

Context files provide persistent reference for AI coding sessions across
all projects and the ein-ai-proxy codebase specifically.
2026-03-26 18:22:48 -05:00

73 lines
2.2 KiB
Markdown

# 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
```bash
# 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`:
```json
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai.ein-softworks.com",
"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.ein-softworks.com`
## 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
- `deploy.sh` — Deployment script
- `CLAUDE.md` — Project-level context for AI agents
- `CONTEXT.md` — Full infrastructure documentation
## License
MIT