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?"
Opik is the open-source LLM observability and evaluation platform, built by Comet. opik-cipx is its cost lens for Claude Code.
Status: actively developed, versioned v0.0.x. This repo is the public
distribution point: it ships the prebuilt binaries (see
Releases) for
macOS, Linux and Windows (amd64 + arm64 each) and the Claude Code plugin. The
source lives in the private
comet-ml/cost-intelligence-proxy-internal
repo; each release is built from there.
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 tools, 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 aware — subagent calls are captured and peer under the same
session.
- MCP attribution — MCP tool definitions and results are bucketed
separately so you can see what your MCP servers cost.
- Survives Opik outages — a 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 (or
install.ps1 on Windows, see below), then restart Claude Code — the
SessionStart hook runs opik-cipx sync, which wires everything up.
Windows needs Git for Windows: Claude
Code runs command hooks through Git Bash there (and clones marketplaces with
git), so the plugin's bash launcher runs unchanged and picks the
bin/opik-cipx-windows-<arch>/opik-cipx.exe binary. PowerShell-only machines
are not supported. WSL counts as Linux.
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:
curl -fsSL https://raw.githubusercontent.com/comet-ml/cost-intelligence-proxy/main/install.sh | bash