Claude Code CLI
Claude Code uses the Anthropic SDK under the hood, so the ANTHROPIC_BASE_URL shim is enough to route every call through TokenOps.
Setup
Start the daemon:
bashTOKENOPS_STORAGE_ENABLED=true tokenops startPoint Claude Code at the proxy:
bashexport ANTHROPIC_BASE_URL="http://127.0.0.1:7878/anthropic" export ANTHROPIC_API_KEY="sk-ant-..."Launch Claude Code as usual:
bashclaude
Smoke test
bash
./scripts/smoketest-claude-code.shSends a one-shot Anthropic messages request through the proxy and asserts a fresh PromptEvent landed in ~/.tokenops/events.db.
Troubleshooting
- 403 on Claude Code launch — the proxy stripped a header. Check
tokenopslogs for "upstream error"; usually a staleanthropic-version. - TLS errors — Claude Code does not ship a custom CA store. Run TokenOps without TLS in dev (default) or trust the local CA via
tokenops cert install. - No events in store — confirm
TOKENOPS_STORAGE_ENABLED=truewas set beforetokenops start. Storage is opt-in.