# pi Cost Tracking: No Native Hook, So Cost Comes From the Proxy

pi has no built-in cost tracking, and its extension events never see token counts. To get per-call cost you route pi's model traffic through the ACP proxy. The config, what you get, and what the tool-call extension can't tell you.

<div class="acp-shot-frame">
<img src="/assets/img/screenshots/session-trace-dark.png" alt="An ACP session trace: each model call priced with its token and cached-token counts, interleaved with the tool calls it drove" style="width:100%;height:auto;border:1px solid var(--line-2);border-radius:10px;box-shadow:0 20px 50px -24px rgba(0,0,0,0.9);margin:8px 0;" />
</div>

<div style="margin:8px 0 28px;padding:20px 22px;border:1px solid var(--line-2);border-radius:12px;background:var(--color-accent-light,#f0effe);">
  <p style="margin:0 0 12px;font-size:15px;line-height:1.6;color:var(--acp-text);"><strong>Just want the answer?</strong> pi has no cost hook, so you change where the model traffic goes. Install the tool-call extension, then add a provider for the cost X-ray:</p>
  <pre data-track="PiCost: Hero Config Copy" style="margin:0 0 12px;background:var(--color-surface,#faf9ff);border:1px solid var(--line-2);border-radius:8px;padding:12px 14px;overflow-x:auto;"><code>curl -sf https://agenticcontrolplane.com/install.sh | bash

# ~/.pi/agent/models.json
{
  "providers": {
    "acp": {
      "baseUrl": "https://api.agenticcontrolplane.com/v1",
      "api": "openai-completions",
      "apiKey": "!cat ~/.acp/credentials",
      "compat": { "supportsDeveloperRole": false, "supportsReasoningEffort": false },
      "models": [{ "id": "gemini-3.5-flash" }]
    }
  }
}
# then: pi --model acp/gemini-3.5-flash</code></pre>
  <p style="margin:0;font-size:13px;color:var(--acp-text-dim);"><a href="/integrations/pi" data-track="PiCost: Integration Guide" style="font-weight:600;">Full pi install guide →</a> &nbsp;·&nbsp; <a href="/controls/pi" data-track="PiCost: Controls Reference">pi's control model, explained →</a></p>
</div>

pi is small on purpose: four tools, no permission system, and you extend it yourself. That also means there is nothing to hook for cost. The two events an extension gets, `tool_call` and `tool_result`, fire on tools. They see arguments and results. They never see a token count or a model's usage fields. pi's core loop talks to the model provider directly, outside the extension pipeline, so an extension can't intercept a model call the way it intercepts a tool call.

That puts pi closer to [Codex CLI](/blog/codex-cli-cost-tracking) than to [Hermes](/blog/hermes-cost-tracking). Hermes has an in-process hook on every model request. With pi and Codex, the only way to see what a call cost is to change where it goes.

## What the extension covers

The [ACP extension for pi](/controls/pi) checks every tool call. `tool_call` fires before each `bash`, `read`, `write`, `edit` or custom tool call and can deny it or rewrite it. `tool_result` fires after and can redact or rewrite what the model reads back. pi has no MCP layer and no second way to dispatch a tool, so that pair sees everything the agent does.

It doesn't see what the model calls cost. So the extension gets you allow, ask, deny and redact on tool calls, plus an audit trail, and nothing about spend. With no UI (`pi -p` or piped input), an ask is denied on the spot. A held call otherwise waits on the console or the approval email. You approve it there, then ask the agent to retry.

## The config

pi can send model calls through the ACP proxy the way any OpenAI-compatible client can. Add a provider entry in `~/.pi/agent/models.json`:

```json
{
  "providers": {
    "acp": {
      "baseUrl": "https://api.agenticcontrolplane.com/v1",
      "api": "openai-completions",
      "apiKey": "!cat ~/.acp/credentials",
      "compat": { "supportsDeveloperRole": false, "supportsReasoningEffort": false },
      "models": [{ "id": "gemini-3.5-flash" }]
    }
  }
}
```

Then start pi against it:

```bash
pi --model acp/gemini-3.5-flash
```

The proxy reads the usage fields on the way through and prices the call. The call shows up as a row next to the tool-audit rows for the same session, in [the console](https://cloud.agenticcontrolplane.com).

## What you get once it's routed

Calls made with `--model acp/...` show the same cost picture described in [turning on the cost X-ray](/cost-tracking):

- **Per-call cost.** Tokens in and out, priced in dollars, rolled up per run.
- **Prompt-cache hit rate.** A cold cache can double a session's cost without anyone noticing.
- **Loop versus leaf.** How much of the spend is the agent re-reading its own context to pick the next step, and how much is doing the work.

None of this shows up while pi still points at its default provider. The extension and the provider entry are independent. You can run the extension alone (tool-call checks, no cost), the provider alone (cost, no tool-call checks), or both. Both gets you one console with everything.

One thing to know: with this entry, pi's model calls go through ACP's model broker instead of your own provider login. Check the [pi integration guide](/integrations/pi) for how those calls are billed before you point a long run at it.

## Troubleshooting

**I added the provider but see nothing in the console.** Check that you started pi with `--model acp/<id>`. Adding the block to `models.json` makes the option available. It doesn't change pi's default model.

**`"apiKey": "!cat ~/.acp/credentials"` fails.** That syntax runs a shell command to read the file at launch. Confirm the file exists and holds a workspace key (`gsk_...`), which the install script writes when you sign in. A missing or malformed file means pi can't authenticate the request. It doesn't mean the proxy is down.

**Tool-call rows show up but cost rows don't, or the other way round.** That's expected if only one of the two pieces is installed.

## Frequently asked questions



## Where to read more

- [pi's control model, explained](/controls/pi): what the extension covers, and where its two events end
- [Prime Agent cost tracking](/blog/prime-agent-cost-tracking): the same proxy pattern on pi's hard fork
- [Hermes Agent cost tracking](/blog/hermes-cost-tracking): the in-process hook, for comparison
- [Claude Code cost tracking reference](/blog/claude-code-cost-tracking-reference) and [Codex CLI cost tracking](/blog/codex-cli-cost-tracking)
