Skip to main content
This page is for an app where each signed-in person talks to a voice model: a phone or browser client, a monthly allowance per person, and a cap on the whole product. The audio runs from the client to the vendor. The gateway holds the provider keys, admits each call against the budgets, meters it and stops it at the limit.

Pick how you cap each person

There are two ways to give each end user an allowance. Both work on every route on this page. Use a key per end user when the client calls the gateway directly. The key is the person’s credential: it carries their budget and their concurrency cap, and it is revoked alone. Use the per-end-user budget when every request already passes through your backend. Your backend holds one key and names the person on each request. The product-wide cap is a project budget in both cases. A request is checked against every budget that applies, so a person at 5 USD is stopped by their own cap and the product at 50 USD is stopped by the project’s.

Set up a key per end user

Create the project budget once:
Create a key when a person signs up. Send an Idempotency-Key so a retry returns the same key:
The response carries the secret once. Hand it to that person’s client over your own authenticated channel and store it in the platform keychain. See Virtual keys for the full body.

Set up one per-end-user budget

Your backend sends X-LangWatch-End-User-Id: <your user id> on every request, voice session creates included. A voice session keeps the end user it was created with: every usage report of that session counts against that person’s bucket. See Budgets.

Which route for which feature

Prefer the routes the gateway meters. A client that reports its own usage can stop reporting, and the gateway then charges an estimate for the session instead of what it used.

A call, end to end

To call from a browser, list your page’s origin in LW_GATEWAY_CORS_ALLOWED_ORIGINS on the gateway. See Calling the gateway from a browser. The client creates its WebRTC offer and posts it to the gateway with its key:
The gateway adds one HTTP round trip before the call starts. The audio does not pass through it, so the call itself gains no latency. What the client has to handle:

How far past the limit a call can go

A budget is checked when the call is created and again while it runs.
  • Calls the gateway meters are ended by the gateway. It checks on every usage report and every 30 seconds, so a call runs at most about one minute past the limit.
  • Sessions the client meters cannot be ended by the gateway. Each usage report answers with budget.exceeded; close the socket when it is true. A client that ignores it is bounded by the credential lifetime and the vendor’s maximum session length, and the next mint answers 402.
See Budgets.

See what each person spent

With the per-end-user budget, read one person’s spend with GET /api/gateway/v1/end-users/:id/spend. Signed spend events for your own ledger are described in Metering and rebilling.
Last modified on October 12, 2026