# TokenPolice

> Monitor every AI dollar. Control it in real time. TokenPolice meters every LLM call and blocks or reroutes it before the provider request is made. Not a proxy: prompts never leave your servers. 13 providers and 7 frameworks, Node and Python.

HTML: https://tokenpolice.ai/

TokenPolice meters every LLM call an AI app makes and enforces the rules you set before the provider is called. It is an in-process SDK, not a proxy and not a gateway: it runs beside the call, inside your own process, rather than carrying the request. Observability tools record cost after a call finishes; TokenPolice decides before it is made. Set a dollar limit per user, plan, session or workflow; over the line it blocks the call, reroutes it to a cheaper model on the same provider, or notifies you. Fail-open if unreachable.

An in-process SDK (Node.js and Python, two lines to install) sends token metadata — model id, token counts, USD cost, the identifiers you choose, and a content fingerprint used for loop detection — to the TokenPolice service. TokenPolice never receives raw prompt or completion text.

What that buys, before any rule is written: every call priced and attributed — by user, plan, feature, model, provider, session, workflow and trace — with the agent runs laid out span by span, and the blocked, rerouted and would-have-been-blocked calls on the same timeline. That is the half of the product you read. The rules are the half that acts, and they run off the same metadata, which is why neither half needs the prompt.

Live demo: https://tokenpolice.ai/demo is the real dashboard running on a seeded fixture — no account, no backend, every screen clickable, and every number in it fictional. Map of the screens: https://tokenpolice.ai/demo.md.

Coverage: 13 providers and 7 frameworks across Node and Python. Providers: OpenAI, Anthropic, Amazon Bedrock, Google Gemini, Cohere, Mistral, Groq, OpenRouter, Cerebras, Together, Hugging Face, xAI (Grok) and Voyage. Frameworks: LangChain / LangGraph, Vercel AI SDK, LlamaIndex, OpenAI Agents SDK, Pydantic AI, CrewAI and Agno. Non-chat calls are metered too — embeddings, images, text to speech, speech to text, video and OCR — and each carries its own operation tag, so a rule can target one without touching chat traffic. Calls made through a provider's OpenAI-compatible endpoint are metered and attributed from the base URL. Full matrix, with caveats: https://tokenpolice.ai/docs/integrations/matrix.md

## Where to read next

- [Docs](https://tokenpolice.ai/docs.md): overview; per-page index at https://tokenpolice.ai/docs/llms.txt
- [Solutions](https://tokenpolice.ai/solutions.md): the five bill failures and the rule for each
- [Pricing](https://tokenpolice.ai/pricing.md): Free 10,000 guarded requests a month; Pro $49/mo for 50,000; Scale
- [Live demo](https://tokenpolice.ai/demo.md): seeded clickable dashboard; HTML at /demo
- [Blog](https://tokenpolice.ai/blog)
- [Site index for agents](https://tokenpolice.ai/llms.txt)

## FAQ

### How is this different from an observability tool?

Observability tells you what a call cost, once it has finished. TokenPolice checks the limit you set before the call is made, then blocks it, sends it to a cheaper model on the same provider, or allows it. It is also the trace, the per-call model log and the audit log for that traffic, priced per user, plan, session and workflow — all of it built from token metadata rather than from your prompt text. What it deliberately does not do is prompt replay or evals: if you need to read back what was in a prompt, that needs a tool that stores them, and this one never receives them.

### Do you see my prompts?

No. The SDK runs inside your process and sends token metadata: the model id, token counts, the cost in USD, the identifiers you choose such as user, plan and session, and a content fingerprint used for loop detection. Raw prompt and completion text never leave your servers.

### What happens if TokenPolice goes down?

Your app carries on. If the service is unreachable the check fails open, the call proceeds, and you lose enforcement for that moment rather than uptime. TokenPolice is never a hard dependency of your request path.

### Which providers and frameworks are supported?

The SDK meters 13 providers and 7 frameworks across Node and Python, most of them on the plain install. Providers: OpenAI, Anthropic, Amazon Bedrock, Google Gemini, Cohere, Mistral, Groq, OpenRouter, Cerebras, Together, Hugging Face, xAI (Grok) and Voyage. Frameworks: LangChain / LangGraph, Vercel AI SDK, LlamaIndex, OpenAI Agents SDK, Pydantic AI, CrewAI and Agno. Embeddings, images, speech, video and OCR are metered as well as chat, each under its own tag so a rule can target one without touching the others. The full matrix with every caveat is at tokenpolice.ai/docs/integrations/matrix, and the tested versions are at tokenpolice.ai/docs/sdk/supported-versions.

### Can I cap free users and paid users differently?

Yes. That is the common first rule: one dollar limit per free user, a larger one per paid user. You can also put a single shared limit on the whole free tier, so a flood of new free accounts is bounded in total rather than one account at a time.
