AI usage metering UsageFlow
Meter AI usage per customer — and act on it while it runs.
AI usage metering records the tokens, requests and cost of each OpenAI or Anthropic call and attributes them to a customer. UsageFlow then routes, caps, or blocks the next call based on that usage.
Free: 1 workflow with live policy. No credit card. Stripe sync is on paid tiers — see pricing.
Per-customer token and cost ledger
Your provider shows one total. You need one per customer. The provider's dashboard shows usage for a key. At the end of the month there is one invoice, and no answer to which customer spent what.
That is hard to price, hard to limit, and hard to explain to a customer who asks why they were charged.
What a key-level view shows
One number for everyone.
key sk-...a41f this month 3,480,000 tokens by customer not available
What a per-customer ledger shows
A running total per identity.
cust_acme 412,000 cust_globex 62,000 cust_initech 104,000 cust_umbrella 18,000 cust_hooli 9,000
What AI usage metering records
Every call through the SDK adds to the customer's ledger. This is exactly what is counted.
| Call | What is added to the ledger |
|---|---|
| Chat and streaming | Input tokens plus output tokens actually used |
| Embeddings | Input tokens |
| Withdraw and credit | The amount you set. You choose the unit; it is not converted. |
The ledger resets on the schedule your policy sets: daily, monthly, yearly, or never.
SDK example: TypeScript, Python and Go
Four ideas, in the order you meet them, then the code.
-
Identity: whose usage is this
Pass your customer ID with every call. Use the same ID you use in Stripe. The first call with a new identity creates its ledger automatically.
-
Ledger: how much they have used
One running total per identity. Policies compare against this number.
-
Policy: what happens as it grows
A short ladder of tiers you edit in the Console. Tiers can route to a cheaper model, degrade the request, or block it, and they apply to the next call without a deploy.
-
Settlement: what really happened
UsageFlow reserves a worst-case amount before the call, then records what the provider actually used.
Enforce plan limits at runtime
Metering only matters if something happens when a customer uses a lot. Policies act before the next call runs.
Report usage to Stripe
What you limit and what you invoice come from the same numbers. Connect Stripe in four steps.
-
Add your Stripe API key
Connect your Stripe account in the UsageFlow Console.
-
Add a Stripe meter effect to your policy
Each call's usage is reported to your Stripe meter.
-
Set the Stripe event name
Use the event name of the meter you created in Stripe.
-
Match the customer
Use the same identity as your Stripe customer so usage lines up with invoices. Stripe sync is on paid tiers.
How to choose an AI usage metering tool
Seven questions to ask any tool, and how UsageFlow answers each.
| Ask | Why it matters | UsageFlow |
|---|---|---|
| Counts per customer? | A per-key total can't price or limit individual customers. | One ledger per identity. |
| Acts before the call? | Alerts after the fact don't stop the spend. | Policy runs before the provider is contacted. A blocked call costs nothing. |
| Covers your providers? | Teams mix models and vendors. | OpenAI and Anthropic through one call shape. |
| Settles to real usage? | Estimates drift from the invoice. | Reserves a worst-case amount, then records what ran. |
| Keeps prompts private? | Prompts can be sensitive. | Prompts and responses go from your server to the provider, not through UsageFlow. |
| Connects to billing? | Limits and invoices should match. | Stripe meter effect on the same usage. |
| Changes without a deploy? | Pricing and limits change often. | Edit policies in the Console and they apply to the next call. |
Keep going
AI usage metering FAQ
Straight answers for the category questions.
What is AI usage metering?
AI usage metering records the tokens, requests and cost of each AI call and attributes them to a customer, so you can see and control what every customer consumes.
Can I limit AI usage per customer?
Yes. UsageFlow policies use each customer's current usage to route to a cheaper model, cap the budget, or block a request before it runs.
Can I report AI usage to Stripe?
Yes. Add a Stripe meter effect to the policy and UsageFlow reports each call's usage to your Stripe meter. Use the same identity as your Stripe customer so usage lines up with invoices.
Know who used what before the invoice does
Free: 1 workflow with live policy. No credit card. TypeScript, Python and Go, with OpenAI and Anthropic. Stripe sync is on paid tiers — see pricing.