Download PDF

A Local Gateway for Headless Claude and Codex

M Walker

10 October 2026

I built a personal gateway that gives every agent I write one OpenAI-compatible endpoint. Role aliases decide whether a call goes to headless Claude Code, headless Codex or an API model, and every call leaves a proof record.

At a glance

The gateway is LiteLLM 1.104.0 on 127.0.0.1, hash pinned, with two custom providers I wrote: one runs claude -p and the other codex exec, both on my own logins. Every model call in my Offerings Atlas went through it, 302 of them on 10 October 2026 alone, at no marginal cost.

Why

I wanted the agents in my projects to call models the way production code would: one API, structured output, a role name instead of a model name. I did not want to pay API rates for every experiment while I build, and I did not want a coding assistant's tools, memory or instructions leaking into calls that are meant to be a clean judgement.

How the LLM gateway routes a call Agents and scripts call one OpenAI-compatible endpoint on 127.0.0.1 port 4000 with a role alias such as judge. LiteLLM maps the role to a route: claude -p on the Claude subscription, codex exec on the ChatGPT login, or an API model. CLI routes run locked down with no tools, an empty working folder, one turn and no saved session, and pass the caller's JSON schema to the CLI. Every CLI call appends a proof record with prompt hashes, models used, tokens and the raw output. CALLERS Evaluator agent Questionnaire Any script model="judge" model="claude-cli-sonnet" response_format: json_schema ONE LOCAL ENDPOINT LiteLLM on 127.0.0.1:4000 A local password, role aliases, a hash-pinned install SUBSCRIPTION ROUTE claude -p, headless Haiku or Sonnet, schema passed to --json-schema SUBSCRIPTION ROUTE, EXPERIMENTAL codex exec, headless The second model family, schema to --output-schema API ROUTE, FOR HOSTED RUNS An API model Moving a role here is one line of config EVERY CLI CALL No tools, empty working folder, one turn, no saved session, API keys stripped Then one proof record: prompt and schema hashes, models used, CLI version, tokens, duration and raw output

How it works

Callers ask for a role such as judge. One line of configuration maps the role to a route, so moving the judge from Haiku on my subscription to an API model for a hosted run is a one-line change. A JSON schema in the request goes straight to the CLI's own schema flag, so the caller gets valid JSON back or a clear error.

Each CLI call is locked down:

Each call then writes one proof record: hashes of the system prompt, the prompt and the schema, the model requested and the models actually used, the CLI version and login method, tokens, duration, the tool's notional cost and the raw output.

In use

MeasureValue
Calls through the gateway on 10 October 2026302
Sonnet judge call on a real knowledge base cellabout 6 seconds and 14,500 input tokens
Haiku judge call on a test caseabout 5 seconds and 2,800 input tokens

Two practical lessons came out of running it hard. Several Claude sessions refreshing the same login at once can make a call fail for a few seconds, so callers retry with backoff. And Codex loads its home folder's instructions even with user configuration ignored, so the gateway supports a separate Codex home with its own login.

Limits

Figures come from the gateway's own proof log as of 10 October 2026.