Back to changelog

Project Budgets and Budgets in the Master API

Cap what a whole project can spend with an all-time limit, a recurring limit, or both, enforced on every inference endpoint. Member and team budgets can now be read and set from your backend through the master API.

A glowing gauge with a hard stop marker on a circuit board chip, surrounded by coins, a folder, a calendar and a lock on small pedestals

Per-key spend limits stop one key. They do not stop a project with twenty keys, a team that keeps creating new ones, or a forgotten key that was deleted after it spent its share. Project budgets put one hard cap on everything a project spends.

Project Budgets

A project now has two independent limits:

Limit What it caps
All-time Lifetime spend of the project
Recurring Spend over a rolling window of 1 hour to 12 months

Spend counts every API key in the project, including keys that were disabled or deleted later, and covers both LLM Gateway credits and your own provider keys. End-user sessions from embeddable payments are funded by their own wallets and are outside the project budget. Set the budget under Settings → Preferences in the project. Only organization owners and admins can change it; project admins can see it but not raise it.

When the budget is reached, every endpoint that runs inference rejects the request with 401 and the error code project_usage_limit_exceeded, before the request reaches a provider:

1{2  "error": {3    "message": "Unauthorized: LLMGateway project reached its usage limit.",4    "type": "invalid_request_error",5    "param": null,6    "code": "project_usage_limit_exceeded"7  }8}

Requests work again as soon as you raise or remove the limit, or once enough spend leaves a recurring window. Batch requests that hit the limit wait and retry instead of failing. Free requests on chat completions are never blocked, and retrieving finished videos stays available.

The budget is enforced against recorded spend, which refreshes about once a minute, so traffic can run past a limit while recent spend catches up; how far depends on your traffic and request costs. If spend cannot be read at all, for example during a database outage, the check lets requests through rather than blocking all traffic.

Set the same limits from your backend with a master key. Master keys are available on the Enterprise plan:

1curl -X PATCH https://internal.llmgateway.io/v1/master/projects/$PROJECT_ID \2  -H "Authorization: Bearer $MASTER_KEY" \3  -H "Content-Type: application/json" \4  -d '{5    "periodUsageLimit": "500.00",6    "periodUsageDurationValue": 1,7    "periodUsageDurationUnit": "month"8  }'

Every change is recorded in the audit log as project.budget_update.

Member and Team Budgets in the Master API

The member budgets and team policy from the Team page are now available to the master API on the Enterprise plan, so a platform team can provision limits from its own tooling:

Endpoint Does
GET /v1/master/members/{member}/budget The member's own, effective and team budget, plus spend
PATCH /v1/master/members/{member}/budget Sets the member's spend limits and maximum API keys
GET /v1/master/teams Lists teams with their budgets
PATCH /v1/master/teams/{id}/budget Sets a team's per-developer ceiling

{member} takes a membership id or an email address. Both resources use usageLimit, periodUsageLimit, periodUsageDurationValue, periodUsageDurationUnit and maxApiKeys; null clears a limit. Changing a team budget needs the Enterprise access control feature, as in the dashboard; reading one does not.


Project budgets docs → | Master API docs →