AI Gateway
Know what every end user costs. Stop them before they overspend.
Every model call your agents make goes through the gateway. It is recorded with its tokens and cost against the agent, the end user, the API key and the use case, and checked against your limits before it reaches the provider.

Attribution
Every call, split by who and what made it.
Group usage by any dimension, over today, 7 days, 30 days or this month. Costs use each provider’s list price; cached input and what caching saved are shown on their own. Tag a call with any key and value and the same tag groups this page, filters traces and can carry a limit.
- Use case
- Agent
- End user
- Source
- Model
- API key

End users
Name the person once. Every surface counts them.
Your server names the person, so they cannot spoof it: per call with a header, or on a short-lived token you give to their browser. People messaging a bot on Telegram, WhatsApp or Discord are identified automatically.
# From your server: name the person on each callcurl https://api.distri.dev/v1/agents/support_assistant \ -H "Authorization: Bearer $DISTRI_API_KEY" \ -H "X-Distri-End-User: usr_8812" \ -d '{ "jsonrpc": "2.0", "id": "1", "method": "message/send", ... }'
# Or mint a token for the signed-in person and hand it# to the embed or @distri/react in their browsercurl https://api.distri.dev/v1/token \ -H "Authorization: Bearer $DISTRI_API_KEY" \ -d '{ "scope": "user", "identifier_id": "usr_8812" }'# → { "access_token": "…" }Limits
Caps checked before every provider call.
Cap tokens, cost in USD, or both, per day, per rolling week or per month. A call over the cap is refused before it reaches a model, answers 429 with when it resets, and shows as Blocked. The dashboard flags a limit that is used up.
A limit can apply to
- Workspace
- Agent
- Use case
- Tag
- End user
- API key
- Embed client

# Cap one end user at $0.50 a daycurl -X PUT https://api.distri.dev/v1/gateway/limits \ -H "Authorization: Bearer $DISTRI_API_KEY" \ -d '{ "scope": "end_user", "scope_value": "user:api:usr_8812", "period": "day", "max_cost_usd": 0.5 }'
# The next call over the cap never reaches the model:HTTP/1.1 429 Too Many Requests{ "message": "End user user:api:usr_8812's daily limit of $0.50 is used up. It resets at 00:00 UTC." }Reports
Where the spend, tokens and failures go.
Ready-made reports for the questions finance and engineering ask, each with a CSV export. Build your own view in Explore and save it for the workspace.


Traces
Open any call and see why it cost what it did.
Every agent run, bot and workflow run, and direct model call is a trace: a tree of agent, model and tool spans with timings, tokens and cost. Filter by end user, use case, tag or agent, or show only the failures.
Models and keys
Any provider. Your keys. A model per agent.
Agents run on the free tier until you add your own key; then the provider account, its rates and its data terms stay yours. Pick a default model for the workspace and a different one for any agent. Test a connection and try models in the playground.
- OpenAI
- Anthropic
- Google Gemini
- Google Vertex AI
- Azure AI Foundry
- AWS Bedrock
- Alibaba Cloud
- Z.ai
- Cloudflare Workers AI
- fal.ai
- ElevenLabs
- OpenAI-compatible

Put a price on every conversation.
The gateway is part of every Distri workspace, free tier included.