Langfuse launches AI Gateway Learn more
DocsBudgets

Budgets

Beta. The Langfuse AI Gateway is in public beta and can still change.

Budgets are spend limits: they cap what gateway traffic may cost in USD. Once a budget is reached, the gateway rejects new requests until the budget resets. Requests that are already in flight still complete.

You manage budgets under AI Gateway → Budgets.

Budgets page with the organization budget, spend over time, and a table of gateway keys with their spend against each budget

Budget types

BudgetCapsWho can set it
API keyOne gateway keyAdmins and owners, and any user on their own keys
UserAll gateway keys of one userAdmins and owners
DefaultEach key or user without its own budgetAdmins and owners
OrganizationAll gateway spend of the organizationAdmins and owners

A request counts against every budget that applies to it: its key's budget, the key owner's user budget, and the organization budget. Whichever is reached first blocks the request.

Set a budget

Select Add budget, or Edit budget on a row in the Users or API keys table. You can also set a budget when you create a key.

A budget resets daily (00:00 UTC), weekly (Monday), monthly (on the 1st), or never. It counts spend from when you set it. Changing the amount keeps the spend counted so far; changing the reset interval starts counting again.

Spend is calculated from model prices, so a key with a budget can only call models that Langfuse has a price for.

Default budgets

A default budget applies to every key, or every user, that has no budget of its own, including service account keys. Each key or user counts its own spend against the default; they don't share it. Admins and owners set one default for keys and one for users, from the API keys and Users tables.

A key's or user's own budget replaces the default. Removing it puts the key or user back on the default.

Organization budget

The organization budget caps the total gateway spend of the organization, across all users and keys. An organization has one organization budget. Admins and owners set it on the Budgets page, which also shows its current spend.

When a budget is reached

The gateway responds with 429 and the error code spend_limit_exceeded, and the message names the budget, for example: This key's user has spent $12.00 of its $10.00 monthly budget. See AI Gateway errors for the full list of error codes.

When a key or user budget is reached, the key owner or user and the organization's owners get an email.


Was this page helpful?

Last updated on