Cost Intelligence Proxy for Claude Code (opik-cipx)
opik-cipx is a local reverse HTTP proxy that sits between Claude Code and
the Anthropic API. Claude Code routes through it via ANTHROPIC_BASE_URL;
opik-cipx owns the TLS leg to api.anthropic.com. It captures every call on
the wire, categorizes input/output bytes into cost buckets — system prompt,
tools, memory, agents, skills, MCP, user input, tool I/O — and ships
per-call spans to Opik so you can answer
"where did my tokens go and how much did they cost?"
Status: pre-release scaffolding. Releases tagged v0.0.x exercise the
build pipeline; the binaries do not yet do useful work. Wait for v0.1.0+
before deploying for real. Source lives in
comet-ml/cost-intelligence-proxy-internal
(currently private).
Features
- Wire capture — totals come straight from Anthropic's
response.usage,
so token counts and costs are exact, not estimated.
- Per-category attribution — request + response bytes are bucketed (system
prompt, builtin tools, MCP servers, skills, memory, custom agents, prior
assistant turns, tool I/O, user prompts, …) using chars-proportional math
over the actual wire bytes. No tokenizer dependency.
- Subagent + compaction aware — subagent calls peer under the same trace;
/compact triggers carry a cc.compaction flag with size deltas.
- MCP per-server breakdowns — see which MCP server is costing you tokens.
- Survives Opik outages — local WAL spools spans; the shipper drains when
Opik comes back.
- Single binary —
opik-cipx is the long-lived gateway and the
short-lived process Claude Code's SessionStart hook invokes (subcommand
opik-cipx sync).
How it works
┌──────────────────────┐ ┌─────────────────────────────┐
│ Claude Code │ HTTP │ opik-cipx (127.0.0.1:9909) │ TLS
│ ANTHROPIC_BASE_URL ─┼────────►│ reverse proxy ─────────────┼──► Anthropic API
│ http://127.0.0.1:99 │ │ capture req + resp │
└──────────────────────┘ │ categorize + build span │
│ WAL spool → Opik shipper │
└────────────────┬────────────┘
│
▼
Opik
The plugin's SessionStart hook execs opik-cipx sync on every Claude Code
launch. sync is idempotent: it installs the OS supervisor (launchd /
systemd) so the daemon auto-restarts on crash, brings the daemon up if it
isn't already running, and upserts ANTHROPIC_BASE_URL into
~/.claude/settings.json so Claude Code routes through
http://127.0.0.1:9909. No filesystem-level CA installs, no per-host MITM
cert dance — Claude Code talks plain HTTP to the loopback listener and
opik-cipx is the only thing holding a TLS session to Anthropic.
Install
Claude Code plugin (recommended)
From within Claude Code:
/plugin marketplace add comet-ml/cost-intelligence-proxy
/plugin install opik-cipx@opik-enterprise
The plugin installs the SessionStart hook that keeps the opik-cipx gateway
alive between Claude Code sessions, plus the /opik-cipx:opik-cipx skill
(how it works + diagnostics). The hook tolerates a missing binary — it just
prints a hint to install opik-cipx and lets the session continue.
The plugin ships the binary in its own tree, so a clean plugin install needs
nothing more. For a non-plugin setup, drop the binary with install.sh (see
below), then restart Claude Code — the SessionStart hook runs opik-cipx sync, which wires everything up.
Local plugin install (contributors)
If you've cloned this repo locally and want to install your working copy
instead of the published version:
/plugin marketplace add /path/to/cost-intelligence-proxy
/plugin install opik-cipx@opik-enterprise
macOS / Linux (curl, no plugin)
If you'd rather skip the plugin and just run opik-cipx from your shell:
The repo is still private, so install.sh needs a GH_TOKEN with read
access to release assets. Once we go public this drops away.
GH_TOKEN=ghp_yourtoken \
curl -fsSL https://raw.githubusercontent.com/comet-ml/cost-intelligence-proxy/main/install.sh | bash
The installer downloads the latest release for your OS/arch, drops
opik-cipx into ~/.opik-cipx/bin/, and prints the next step. Add that
path to your PATH, then:
opik-cipx sync # supervise + start the daemon and route Claude Code through it
opik-cipx status # confirm it's up
To pin a specific version:
curl -fsSL https://raw.githubusercontent.com/comet-ml/cost-intelligence-proxy/main/install.sh | bash -s -- v0.0.3
Manual download