Skip to navigation

Set the budget of the account

Sets or replaces the budget of the account. A budget is an amount to watch. It never refuses a call: use limit on a key for that. When spend in the window first reaches each of alert_thresholds, Meadow sends one budget.threshold_crossed webhook event and one email, once per threshold per window. See the budgetEvent webhook.

The body replaces the whole budget. Thresholds already crossed in the current window do not alert again.

Scope: admin.

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Request

This endpoint expects an object.
limit_usddoubleRequired

The amount to watch in one window, in US dollars. The name is the one on OpenRouter budgets. A plain JSON number above 0 and below 10^12 with at most 12 decimal places, read as written.

reset_intervalenumRequired

The window. daily starts at midnight UTC, weekly on Monday at midnight UTC, monthly on the first of the month at midnight UTC: the clock of limit_reset on keys.

Allowed values:
hard_limitbooleanOptionalDefaults to false

False, the default: the budget only alerts and never refuses a call. True makes limit_usd a ceiling for the window. Once the dollars counted for the budget reach it, model calls and sandbox creates in its scope are refused with 402 budget_exceeded, and a call whose reserved estimate does not fit what is left is refused the same way. A key in the scope of a hard budget is held to the rules of a key with a dollar limit: a model call must send an output cap, and a route that includes a provider with no price is refused with 403 key_spend_price_unknown.

When it is switched on, the count starts at the window’s spend_usd so far. Sandboxes that are running keep running. Left out of a PUT, it is false: a PUT replaces the whole budget.

alert_thresholdslist of integersOptionalDefaults to [50,75,100]

Percentages of limit_usd that send an alert when spend first reaches them. Whole numbers from 1 to 100, no repeats. Left out, [50, 75, 100]. An empty list sends no alerts.

notification_channelobject or nullOptional
Where alert emails go, shaped as on OpenAI spend alerts. Null or left out sends no email. Webhook events are sent either way.

Response headers

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

Response

The budget as stored, with its spend.
limit_usddouble

The amount to watch in one window, in US dollars. The name is the one on OpenRouter budgets. A plain JSON number above 0 and below 10^12 with at most 12 decimal places, read as written.

reset_intervalenum

The window. daily starts at midnight UTC, weekly on Monday at midnight UTC, monthly on the first of the month at midnight UTC: the clock of limit_reset on keys.

Allowed values:
idstring

The budget id (bud_...).

objectenum

Always budget.

Allowed values:
scopeenum
Whether the budget covers the whole account or one project.
Allowed values:
spend_usddouble

What was spent in the current window, from the usage records: model calls and sandboxes with a known cost. The name is OpenRouter’s.

remaining_usddouble

limit_usd minus spend_usd. It can be negative: an alert-only budget does not stop spend, and one call may end above a hard limit.

resets_atdatetime
When the current window ends.
unknown_cost_recordsinteger

Records in the window with no cost: calls on a provider Meadow has no price for, calls with estimated tokens, sandboxes with no price. When this is above 0, spend_usd is lower than what you were billed.

created_atdatetime
When the budget was first set.
updated_atdatetime
When it was last replaced.
hard_limitbooleanOptionalDefaults to false

False, the default: the budget only alerts and never refuses a call. True makes limit_usd a ceiling for the window. Once the dollars counted for the budget reach it, model calls and sandbox creates in its scope are refused with 402 budget_exceeded, and a call whose reserved estimate does not fit what is left is refused the same way. A key in the scope of a hard budget is held to the rules of a key with a dollar limit: a model call must send an output cap, and a route that includes a provider with no price is refused with 403 key_spend_price_unknown.

When it is switched on, the count starts at the window’s spend_usd so far. Sandboxes that are running keep running. Left out of a PUT, it is false: a PUT replaces the whole budget.

alert_thresholdslist of integersOptionalDefaults to [50,75,100]

Percentages of limit_usd that send an alert when spend first reaches them. Whole numbers from 1 to 100, no repeats. Left out, [50, 75, 100]. An empty list sends no alerts.

notification_channelobject or nullOptional
Where alert emails go, shaped as on OpenAI spend alerts. Null or left out sends no email. Webhook events are sent either way.
project_idstring or nullOptional
The project
enforced_spend_usddouble or nullOptional

The dollars counted against a budget with hard_limit in the current window: the number the 402 is decided on. Null when hard_limit is false. It can be above spend_usd: a call whose cost could not be measured is counted at the estimate that was held for it, and the usage records arrive a little later than the count.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error
500
Internal Server Error