create_budget_gate
Set a monthly LLM spend limit to block over-limit calls before execution. Supports account-wide, project-specific, or tag-based caps.
Instructions
Create a runtime budget gate (Pro+ only). Sets a monthly LLM spend limit (USD) for the account; the SDK (budgetGate opt-in) blocks over-limit calls before execution. Enforcement is optimistic (spend is cached for 60 seconds and in-flight calls pass, so the limit is a guideline that can be exceeded, not a strict hard cap). enforceMode = fail_open (default; calls pass when the backend is unreachable) / fail_closed (calls are blocked when unreachable; a cold start where the SDK has never fetched the config additionally requires the SDK-side failClosed opt-in). Omitting projectId = an account-wide gate (only one; 409 if one exists). Specifying projectId = a gate for that project only (ANDed with the account gate — the strictest limit wins; one per project). Specifying tagKey + tagValue = a gate for calls carrying that tag (e.g. tagKey=service / tagValue=checkout caps the monthly spend of service=checkout. ANDed with the account gate; one per (tagKey,tagValue)). tagKey/tagValue must be specified together and are mutually exclusive with projectId. Example phrasing: "create a budget gate at $50/month" / "cap project X at $10/month" / "cap the service=checkout tag at $20/month"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tagKey | No | Tag key for a per-tag gate (e.g. service). Must be specified together with tagValue; mutually exclusive with projectId. 1-128 chars | |
| enabled | No | Whether the gate is enabled (default true) | |
| tagValue | No | Tag value for a per-tag gate (e.g. checkout). Must be specified together with tagKey. 1-128 chars | |
| projectId | No | proj_-style project ID (omit for an account-wide gate). The project must belong to your account and not be archived | |
| enforceMode | No | Behavior when the backend is unreachable (default fail_open) | |
| monthlyLimitUsd | Yes | Monthly limit in USD (0.01 - 1000000, $0.01 increments). E.g. 50 / 100.5 |