proxy
A local ANTHROPIC_BASE_URL hop that records real token usage and, in compress mode, lets
other plugins rewrite the request.
| Surfaces | rtok proxy [--port 8790] [--upstream URL] [--mode passthrough|compress]; serves ANTHROPIC_BASE_URL and OPENAI_BASE_URL |
| Spec | the spec (replaces) column of the catalogue in plan.md §1 |
| Default | on |
Behaviour
- Forwards
POST /v1/messages(and everything else) toRTOK_UPSTREAM(defaulthttps://api.anthropic.com; may be another local proxy during A/B). - Wire formats (decision D11, phase P11): Anthropic Messages, OpenAI Chat Completions
(
/v1/chat/completions→RTOK_OPENAI_UPSTREAM), OpenAI Responses (/v1/responses). Each is aWireadapter that exposes tool results andusagein one normalised shape;archiveandtoonnever see the raw format. - Streams SSE responses unchanged; parses
usagefrom the finalmessage_deltaor the non-streaming body into theusagetable. passthroughmode changes zero bytes.compressmode runs every enabled plugin’sproxy_filter(today:archive, optionallytoon)./health→{"ok":true,"mode":"passthrough"}.rtok setup claude --proxysetsenv.ANTHROPIC_BASE_URLin settings (with backup) and prints how to revert.
Caveat (research.md §3): setting a base URL disables MCP tool search by default in Claude
Code; rtok doctor flags this.
Tasks
See roadmap.md § proxy. Checks in plan.md.
T5.1 passthrough · T5.2 lifecycle/health/setup · T5.5 cache-health report (with measure) ·
T11.1 Wire adapter · T11.2 OpenAI Chat · T11.3 OpenAI Responses · T11.5 OpenAI host setup.
Status
Manifest only. First task: T5.1.