Coding agent walkthrough
Say the word, answer a few questions, approve the plan, and run once while the agent verifies itself — with a full worked example.
Once the skill is installed, adding TokenPolice is four short touchpoints. Everything else — reading your code, writing the edits, checking the result — the agent does on its own.
We'll follow one real example throughout: a FastAPI support chat that calls OpenAI.
1. Say the word
Ask your agent, in plain language, to add TokenPolice:
You: Integrate TokenPolice into this app.
That's the whole trigger. Wordings like "add TokenPolice", "wrap my agent for
TokenPolice", or "track and enforce LLM spend" work too — and the skill also wakes up on
its own if you mention tp.init, tp.workflow, or TokenPoliceBlockedError.
The agent reads your repo first. For the support chat it comes back with something like:
Agent: Found a FastAPI app calling OpenAI from
chat.py. It's a multi-turn support chat with asession_idper conversation and auser.idon the request. I'll wire TokenPolice around the chat handler. First I need a few things from you.
2. Answer its questions
The agent asks one short batch — nothing it could find in the code itself:
- Your API key — "Create one on the API Keys page (app.tokenpolice.ai/keys). It looks
like
tp_sk_...and is shown only once, so copy it when created. I'll put it in your environment, never in source." See Get your API key. - The collector URL — where usage metadata is sent. The default is
https://collect.tokenpolice.ai; you only change it if you self-host or run a local stack. - Who your users are — which field is the
user_id, which is the plan/tier, and which is thesession_id. For the support chat the agent already spotteduser.idandsession_idand just confirms them. - Dry-run or enforce — it starts in dry-run by default: every call is recorded and you can see what would have been blocked, but nothing is ever blocked. Flipping to enforce later is a one-line change.
- What a blocked call should return (HTTP apps only) — for the FastAPI app,
429 Too Many Requestsor402 Payment Required. Only relevant once you turn on enforce.
It also states the privacy terms up front: TokenPolice receives only token metadata —
model, token counts, your chosen user_id / plan / session_id tags, and a content
fingerprint used for loop detection. Raw prompt and completion text never leave your
servers. See Data & privacy.
3. Approve the plan
Before touching a single file, the agent shows you exactly what it will change:
Agent: Here's the plan:
pip install token-police- Call
tp.init(...)at startup inmain.py, before the OpenAI client is imported, withfirewall="dry_run".- Wrap the chat handler in
chat.pywith@tp.workflow, passinguser_id=user.id,paid_plan=user.plan, andsession_id=session_id.- Add
TOKENPOLICE_API_KEYto your.envand.env.example.Approve?
You reply yes or ask for a change. No code is edited until you approve.
4. Run your app once
The agent makes the edits, then asks you to run the app the way you normally would and send it a couple of messages — a normal request and a multi-turn conversation.
That run is the test. When you say you're done, the agent verifies itself: it checks that TokenPolice actually recorded your traffic (using the same key you already gave it — never your app, never another key) and reports the result:
Agent: Verified — status pass. TokenPolice recorded your calls with the right user and session tags. You're in dry-run mode, so nothing is blocked yet; flip
firewallto"enforce"when you're ready. See your data at app.tokenpolice.ai.
You're done. Open app.tokenpolice.ai and your calls are there, with token counts and cost.
What "verified" means
The agent doesn't call the job done just because the code compiles. It confirms TokenPolice
received real data from your run and that your identity tags came through — then reports
pass, warn (with anything worth knowing), or fail. It won't stop on a fail.
After you're set up
Dry-run vs enforce
Turn on blocking when your rules look right.
Firewall & Budgets
Set the caps and rules the firewall enforces.
Nothing in the dashboard?
Common first-run fixes.
What it did, step by step
The same procedure written out — useful for reviewing the diff.
See it in a running app →
A full support-desk chat with the SDK already wired in — clone and run it.
Install the skill
Install the TokenPolice skill in Claude Code, Cursor, Copilot, Antigravity, or Codex — a one-time setup, then the walkthrough is the same everywhere.
Do it yourself, the way the skill does it
The same steps the TokenPolice skill performs, in order, with the reasoning behind each one and the questions to answer before you start.

