Skip to main content
Glama

Set a key's budget

set_key_budget
DestructiveIdempotent

Set a key's budget

Sets or replaces one key's budget: daily, weekly, monthly and lifetime limits at our price (at least one), the alert share and the mode. limits.monthly becomes the key's monthlyLimitUsd. hard_stop refuses the key's requests with a 402 once a limit is reached (the request that crosses it can go a little over: the check runs before a request, its cost lands after, and the Model API keeps the key's state for about a minute); alert_only never blocks and sends one email per limit and window when the spend crosses alertPct. The account's budget, when there is one, applies too: the key stops at whichever limit it reaches first. Requests follow within about a minute.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "id": "<id>",
      "limits": "<limits>"
    },
    "name": "set_key_budget"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYesThe key id: any working model key of the account, a customer's included (GET /budgets lists them).
modeNohard_stop refuses requests with a 402 at a limit; alert_only never blocks (it needs alertPct above 0).hard_stop
limitsYesLimits in USD at our price, to the cent. At least one; null or left out is no limit.
alertPctNoEmail once per limit and window when the spend crosses this share of a limit. 0 turns the alert off.
idempotencyKeyNoOptional. A unique string so that repeating this call never creates twice.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare destructive and idempotent; the description goes far beyond by explaining that hard_stop returns 402 at a limit, that the crossing request can overshoot because cost lands after the pre-check, and that Model API state lags about a minute. It also discloses alert_only's one-email-per-limit-per-window behavior, the alertPct>0 requirement, and that the key stops at whichever of the key or account limit is hit first — all material context an agent cannot get from the schema or annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded and every clause carries information about limits, modes, or account interplay. It is dense to the point of long run-on sentences (the 402 overshoot caveat in particular), and the title is restated verbatim in the first sentence, which is mild waste but not confusing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, nested-object upsert with no output schema, the description covers the mutation semantics, failure behavior, and eventual-consistency window well. It does not describe what the call returns or any permission/auth prerequisites, which would complete the picture.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: limits are 'in USD at our price, to the cent', at least one limit is required, and limits.monthly maps to the key's monthlyLimitUsd. It reinforces rather than repeats the mode semantics by tying alert_only to an alertPct above 0.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource ('Sets or replaces one key's budget') and immediately enumerates what is set (daily/weekly/monthly/lifetime limits, alert share, mode). The scope qualifier 'one key's budget' plus the note that 'The account's budget, when there is one, applies too' cleanly separates it from the account-level budget siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied rather than stated: 'sets or replaces' signals an upsert against an existing key, and the mention of the account budget clarifies interplay but not routing. There is no explicit 'use get_key_budget to read' or 'use set_account_budget for account-wide limits' guidance, so an agent must infer alternatives from sibling names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources