Build log: claude-cli-proxy

Your subscription, not your API budget

A small local HTTP server that speaks the Anthropic Messages API on the outside and drives the OAuth-authenticated claude CLI on the inside, so any tool expecting the API can bill against a subscription instead of API credits.

Role
Author
Stack
Python · systemd
Years
2026
Status
In service on the home fleet
01 · Problem

Two doors to the same model, priced differently

A local CLI login covers Claude under a subscription, but third-party tools expect the hosted API and its key. The gap is a pricing problem wearing an integration costume.

02 · Shape

Speak the API outside, drive the CLI inside

The proxy presents POST /v1/messages on loopback, validates the request, and executes it through the logged-in CLI. Streaming, model allowlists, timeouts, and per-client profiles included.

03 · Craft

Stateful mode makes it fast without making it fragile

Follow-up turns resume a cached CLI session keyed by a hash of the conversation so far; a lost session is detected, evicted, and retried statelessly without the client noticing.

04 · Shipped

The result: a drop-in bridge that runs as a service

Installed as a systemd user unit with health checks, 46 Python files and 193 automated tests. Small on purpose, and immediately understandable.

193automated tests
1endpoint that matters

Bring the problem nobody's solved.

Start a project