Budget Control Policy Template
Enforce hard daily and monthly spending caps on each AI agent. When an agent reaches its budget limit, Govyn rejects further requests before they reach the LLM provider — no overspend is possible. Configure separate limits per agent, team, or environment.
What this prevents
A startup's LangChain research agent entered a recursive tool-call loop at 2 AM, generating 4,000 completions in 90 minutes. By morning the team discovered a $2,300 OpenAI bill — their entire monthly budget — from a single overnight run. With Govyn's budget control policy, the agent would have been stopped after $5 of daily spend, limiting the damage to under 1% of what actually occurred.
Policy template
Copy this into your govyn.yaml and adjust the values to match your requirements.
agents:
research_agent:
budget:
daily: $5.00
monthly: $100.00
alert_at: 80%
models:
allow: [gpt-4o-mini]
writer_agent:
budget:
daily: $15.00
monthly: $300.00
alert_at: 90%
models:
allow: [gpt-4o, claude-sonnet-4-20250514]
global:
budget:
monthly: $500.00
alert_at: 75%
notifications:
webhook: https://hooks.slack.com/your-channel
on: [budget_warning, budget_exceeded] How it works
Agent sends a request through Govyn
Your AI agent makes an API call to the Govyn proxy instead of directly to the LLM provider. The agent uses a Govyn-issued API key that maps to its budget policy.
Govyn checks the current spend against limits
Before forwarding the request, Govyn looks up the agent's cumulative daily and monthly spend. Token counts from previous requests are tracked in real time.
Request is forwarded or rejected
If the agent is within budget, Govyn forwards the request to the provider and tracks the cost of the response. If the agent has exceeded its limit, Govyn returns a clear 429 error — the request never reaches the provider.
Alerts fire at configurable thresholds
When spend reaches the alert_at percentage (e.g. 80%), Govyn sends a notification to your configured webhook — giving you time to intervene before the hard limit is hit.
Configuration options
| Option | Description | Example |
|---|---|---|
budget.daily | Maximum spend per agent per calendar day (UTC) | $5.00 |
budget.monthly | Maximum spend per agent per calendar month | $100.00 |
budget.alert_at | Percentage of budget that triggers a warning notification | 80% |
global.budget.monthly | Hard cap across all agents combined | $500.00 |
notifications.webhook | Slack or HTTP endpoint for budget alerts | https://hooks.slack.com/... |
Add this policy to your config
Start Govyn with this policy in under 5 minutes. No code changes needed.
Get startedRelated policy templates
Detect and stop AI agent infinite loops automatically. Prevent runaway tool calls and recursive chains with proxy-level loop detection.
Protect production environments from AI agent damage. Model restrictions, rate limits, and approval gates for high-risk operations.
Automatically route AI agent requests to cheaper models when possible. Cut LLM costs by 60-80% with smart model routing policies.
Explore more
How smart model routing through a proxy cut our OpenAI and Anthropic bill from $2,140/mo to $578/mo. Zero code changes. Just YAML.
FROM OUR BLOGHow the Meta email deletion incident could have been prevented with 4 lines of YAML, and why OpenClaw built-in limits are not enough.
INTEGRATIONAdd budget limits, policy enforcement, and full replay to LangChain agents using OpenAI. Five-minute setup, zero code changes.
INTEGRATIONAdd budget controls and policy enforcement to CrewAI multi-agent crews using OpenAI. Govern every agent in your crew independently.