mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
- Merged latest from OpenAI Codex upstream (reasoning effort tracking, apply-patch stability) - Updated branding from 'Codex' to 'Hanzo Dev' throughout codebase - Fixed compilation issues in TUI and core modules - Enhanced build system with hanzo-crypto integration - Preserved Hanzo identity while maintaining upstream compatibility - Updated CLI tooling and MCP protocol implementations - Added comprehensive GitHub Actions integration
3.1 KiB
3.1 KiB
Claude CLI to OpenAI-compatible API Proxy
This proxy enables @hanzo/dev (and other OpenAI-compatible clients) to use your authenticated Claude Hanzo Dev CLI as a backend, without needing API keys.
How It Works
┌─────────────┐ HTTP/JSON ┌─────────────┐ stdin/stdout ┌─────────────┐
│ @hanzo/dev │ ─────────────────► │ Proxy │ ──────────────────► │ Claude CLI │
│ CLI │ ◄───────────────── │ :9999 │ ◄────────────────── │ (claude) │
└─────────────┘ OpenAI-compat └─────────────┘ text └─────────────┘
Quick Start
1. Start the Proxy
cd ~/work/hanzo/dev/cli-proxy
PORT=9999 node claude-proxy.js
2. Configure @hanzo/dev
Add to ~/.hanzo/config.toml:
model_provider = "claude-cli"
model = "claude-cli"
[model_providers.claude-cli]
name = "Claude CLI"
base_url = "http://localhost:9999/v1"
wire_api = "chat"
3. Use @hanzo/dev
# Interactive mode
dev
# Exec mode
echo "What is 2+2?" | dev exec --full-auto
Testing
Direct proxy test with curl:
curl -s http://localhost:9999/v1/chat/completions \
-X POST \
-H "Content-Type: application/json" \
-d '{"model":"claude-cli","messages":[{"role":"user","content":"What is 2+2?"}]}' \
| jq .
Expected response:
{
"choices": [{
"message": {
"role": "assistant",
"content": "4"
}
}]
}
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/v1/models |
GET | List available models |
/v1/chat/completions |
POST | Chat completions (main endpoint) |
Model Mapping
| Request Model | Claude Model |
|---|---|
claude-cli |
Default (Sonnet) |
claude-opus |
claude-opus-4-5-20251101 |
claude-sonnet |
claude-sonnet-4-20250514 |
claude-haiku |
claude-haiku-4-5-20251001 |
gpt-4* |
Default |
Features
- Zero API Keys: Uses your authenticated Claude Hanzo Dev CLI
- OpenAI Compatible: Works with any OpenAI-compatible client
- Multi-Message Support: Handles system/user/assistant roles
- Telemetry Filtering: Cleans JSON artifacts from CLI output
- CORS Enabled: Works with browser-based clients
Requirements
- Node.js 16+
- Claude Hanzo Dev CLI installed and authenticated (
claude --version)
Troubleshooting
Port Already in Use
PORT=8080 node claude-proxy.js # Use different port
Claude CLI Not Found
Ensure Claude Hanzo Dev CLI is installed:
npm install -g @anthropic-ai/claude-dev
claude auth login
Testing the Integration
Run the integration test:
./test-integration.sh
License
MIT - Part of the @hanzo/dev CLI orchestration project.