DEV Community

devtocash
devtocash

Posted on • Originally published at devtocash.com

Claude Proxy: Turn Claude Code CLI into an OpenAI-Compatible API Server

The Problem: Claude Max Has No API Key

You subscribe to Claude Max. You use Claude Code daily. But the moment you try to plug Claude into Cursor, Continue.dev, Aider, or any agent framework that speaks the OpenAI API, you hit a wall: Claude Max has no raw API key.

The Fix: A 300-Line Zero-Dependency Proxy

claude-proxy wraps your local claude CLI and exposes a standard /v1/chat/completions endpoint. Any OpenAI-compatible client can use your authenticated Claude Code session as the backend.

OpenAI-API client --> /v1/chat/completions --> claude_openai_proxy.py --> claude CLI --> Anthropic
Enter fullscreen mode Exit fullscreen mode

3 commands to run. No pip install. No Docker required. Stream and non-stream. Prompt-based function/tool calling with false-refusal hardening.

Supports sonnet, opus, haiku. Concurrency-controlled (200-400MB per CLI process). systemd and Docker deployment included. Evonic integration example in the repo.

Trade-offs

Tool calling is prompt-emulated (not native API), one CLI process per request (stateless), and using Claude Max as a generic API backend may violate Anthropic's ToS. For production, a real API key is the supported path. For internal tools and agent frameworks on a budget, this is gold.

Full architecture breakdown, concurrency design, env var reference, Docker compose, and comparison table -- I walk through every piece at devtocash.com. Repo: github.com/rephapeng/claude-proxy

Top comments (0)