Usage, End Users and Limits
Every model call made through Distri goes through the AI Gateway. The gateway records tokens and cost for each call, ties the call to an agent, an end user and any tags you send, and checks your limits before it reaches the provider.
The AI Gateway section of the dashboard has five pages for this: Traces, Usage, Limits, Reports and End users.

Usage
AI Gateway → Usage shows requests, tokens and cost for a period, split by one dimension at a time.
- Group by: Use case, Agent, End user, Source, Model, API key.
- Period: Today, 7 days, 30 days, This month.
- Cost uses each provider's list price. A model with no list price shows as "unpriced", not $0.
- Cached share of input is the share of input tokens read from the provider's cache. Saved by caching is list price minus what you paid.
- Cost per active end user is total cost divided by the number of end users who made calls in the period.
Each row has a Limit column. Click Add to cap that agent, end user or key from the row.


Tags and use cases
A call can carry tags: any key and value, for example team: growth or activity_id: 123. Tags travel with every model call an agent run makes. The Usage page can group by them, Traces can filter by them, and a limit can apply to one.
The tag key use_case sets the Use case column. A call without it is grouped under its agent's name.
await agent.invoke({
message,
tags: { use_case: 'refunds', team: 'growth' },
});
End users
An end user is a person using your product's AI, in your app, on a bot or through the API. The gateway counts a person as one row only when your server names them. There are two ways to do that.
Name the person on each call
Call the agent from your server with your API key and add the X-Distri-End-User header with your own user id:
curl https://api.distri.dev/v1/agents/support_assistant \
-H "Authorization: Bearer $DISTRI_API_KEY" \
-H "X-Distri-End-User: usr_8812" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "message/send",
"params": {
"message": {
"kind": "message",
"messageId": "m1",
"role": "user",
"parts": [{ "kind": "text", "text": "Where is order 4410?" }]
}
}
}'
Mint a token for the signed-in person
Or mint a short-lived token on your server for the signed-in person and hand it to the browser or the embed:
curl -X POST https://api.distri.dev/v1/token \
-H "Authorization: Bearer $DISTRI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"scope": "user", "identifier_id": "usr_8812"}'
{ "access_token": "…" }
Calls made with that token count against usr_8812. Embed visitors who are not named share one "Anonymous visitors" row.
The End users page
AI Gateway → End users lists each person with where they were seen (API, embed, bot, workflow), sessions, tool calls, cost for the last 30 days and their limit.

Open a person to see their cost by use case and by agent. Set a limit caps that person.

Limits
A limit caps tokens, cost in USD, or both, for one scope over one day. Limits reset at 00:00 UTC. The gateway checks them before every provider call. A call over the cap is refused, shows as Blocked in Traces, and the API answers HTTP 429 with a message such as:
End user user:api:usr_omar's daily limit of $0.00 is used up. It resets at 00:00 UTC.
Scopes: workspace, agent, use_case, tag, end_user, api_key, embed_client.

Set limits on AI Gateway → Limits or through the API.
Create or update a limit:
curl -X PUT https://api.distri.dev/v1/gateway/limits \
-H "Authorization: Bearer $DISTRI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"scope": "end_user",
"scope_value": "user:api:usr_8812",
"period": "day",
"max_tokens": null,
"max_cost_usd": 0.5
}'
For an end user, scope_value is the stored id. People named with an API key and the X-Distri-End-User header are stored as user:api:<your id>. Copy the id exactly as the Usage page shows it when grouped by End user.
List limits with what each has used today (used_tokens, used_cost_usd, exhausted):
curl https://api.distri.dev/v1/gateway/limits \
-H "Authorization: Bearer $DISTRI_API_KEY"
Delete a limit:
curl -X DELETE https://api.distri.dev/v1/gateway/limits/<id> \
-H "Authorization: Bearer $DISTRI_API_KEY"
What your plan includes is listed on the pricing page.
Reports
AI Gateway → Reports has published reports on your workspace's model calls: spend by agent, by end user, by model and by source, spend over time, cache savings over time, failures by model and agent, calls refused by a limit, the largest calls by tokens, and what fills the input.

Each report has a period picker, Export CSV and Open in Explore. In Explore you build your own view and save it as a report for everyone in the workspace.

Traces
Each call on these pages links to its trace: the run, every model call and tool call, with timings, inputs and outputs. See Understanding Traces.