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.

govyn.yaml
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

1

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.

2

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.

3

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.

4

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 started

Related policy templates

Explore more