/v1/end-users. Your backend calls it with the same API key it uses for inference, and renders whatever your product needs: a budget meter, a usage chart, a billing line, an admin table.
What you get
Authentication, scope and permissions
Requests are authenticated with your ManyLayers API key, exactly like an inference call:- Organization-scoped. The organization and workspace come from the key. An end user is unique within your organization, so an id from another organization answers
404 not_found, never someone else’s data. {id}is yours. Address a user by the id you send asuser_id(customer_001) — you do not need to store a ManyLayers id. The ManyLayers registry id (a UUID) also works.- Permissions. Reading needs
gateway.budgets.read, which any Gateway key in the workspace has. Writing budgets or registering users needs an admin-role key — see End-User Budgets. - No prompt content. The API returns counts, tokens, cost, model and timing. It never returns prompts, completions or credentials.
Where the numbers come from
Every metered request writes one usage record: who (organization, end user, API key and the application it belongs to), what (model, provider, endpoint), and the outcome (HTTP status, tokens, cost, latency, streamed or not). The usage API is a read of those records, so:- One source of truth. The budget’s
usedand the usagetotal_costare read from the same usage records. They agree when the governing budget covers every model; a budget limited to one model reportsusedfor that model only (budget.modelis then set), while the usage totals are not narrowed. - Near real time. Records are written asynchronously; a request typically appears in the API within a few seconds of completing, with no guaranteed bound. Enforcement does not wait for it.
- Only attributed traffic. Usage is recorded per end user for chat completions, completions, responses, messages and embeddings. Image, audio, realtime, moderation, rerank, file, MCP and knowledge-base requests, and
/v1/asyncjobs, carry no end-user identity and never appear here. - Failed requests cost nothing. A request that failed (provider error, timeout, refusal) is recorded at
$0when the gateway only had its own token estimate, so a user is never charged for a call that returned nothing. - Cost is USD, rounded to a hundredth of a cent, using the model’s price at request time.
Common query parameters
The usage endpoints share these filters:
All windows are UTC. A malformed
from or to answers 400 bad_request.
Usage summary
GET /v1/end-users/{id}/usage — the one call most UIs need: where the user stands against their budget, plus totals and breakdowns.
The window
With nofrom/to, the window is the current period of the user’s budget: the current month for a monthly budget, today for a daily one, and all time for a lifetime budget. That is why budget.used and usage.total_cost agree by default for an all-models budget. A user with no budget gets the current calendar month. Pass from/to to look at any other range; budget still reports the current standing, not the range.
The budget object
budget is null when no budget applies — and that means spending is uncapped, not that the user has $0. Render it as “no limit”, never as zero. When several budgets cover a user (their own, a workspace default, an organization default), budget is the one that governs the user: their own all-models budget if they have one, otherwise the default that applies (and if several tie, the one closest to its limit). GET /v1/end-users/{id}/budget lists every budget that applies under effective.
Totals and breakdowns
usage and each row of by_model and by_provider share one shape:
by_model rows add model; by_provider rows add provider.
Usage over time
GET /v1/end-users/{id}/usage/daily and GET /v1/end-users/{id}/usage/monthly return one row per UTC day or month, for charts and statements. Without from, daily covers the last 30 days and monthly the last 12 months. Periods with no requests are omitted, so fill the gaps in your UI.
month ("2026-11") instead of date.
Request history
GET /v1/end-users/{id}/usage/requests — a newest-first activity log with per-request cost, for “recent activity” or support tooling.
Pagination is keyset-based, so a page stays stable while new requests arrive. Treat the cursor as opaque, and keep requesting with
after = next_cursor until has_more is false. A cursor you did not get from this API answers 400.
Find users
GET /v1/end-users lists the users registered in your organization (not only the calling workspace), for an admin table.
GET /v1/end-users/{id} returns one user as { "end_user": {…}, "budget": {…} | null }. PATCH changes name, email or status (active / blocked); a blocked user’s requests are refused with 403 end_user_blocked.
Applications
GET /v1/end-users/applications answers “which of my products spend what, and for how many users?”. An application is a virtual account: the identity a product’s traffic arrives on. Each row carries its users and spend, for the current month unless you pass from/to.
end_users counts users who called through the application or were registered from it; active_end_users counts those with requests in the window. A row with an empty application_id is traffic on a key that belongs to no application (a personal key or a console session). A user who called through two applications appears under both, with usage counted per application.
Putting it together
A backend route that returns the signed-in user’s budget to your own frontend:Practices that keep it fast and correct
- Cache on your side. Usage changes at human speed; cache a user’s summary for 10–60 seconds rather than calling the API on every page render.
- Treat
404as “nothing yet”. A user is created by their first request (or by registration), so a never-seen id has no usage. Show zero, not an error. - Treat
budget: nullas uncapped. Do not coerce it to0. - Read the live
402, too. The numbers here lag a little behind real time. The authoritative signal that a user is over their cap is the402 budget_exceededyour inference call returns, which carries the samebudgetfields andnext_reset_at— use it to show “limit reached, resets Dec 1” immediately. - Use the user’s own id. Pass the id you send as
user_id, URL-encoded; you never need to store ManyLayers’ registry ids.
Error responses
All errors use the OpenAI error envelope.See also
Identify end users
Send the user’s id with a header or an SDK.
End-user budgets
Set, change and enforce per-user budgets.