Skip to content
mentoor

Topic 5 of 5 · 5 min read

Budgets, rate limits and spend alerts

Goal: Set spend limits and alerts for a team using coding agents, and predict which limit a heavy user hits first.

Limits protect you only if you know which kind you have: a subscription cap stops the user, a rate limit slows the user, and a spend limit stops the money. They are different controls, set in different places, and a team that mixes them up gets surprised by either a surprise bill or a developer who is locked out mid-task.

Check yourself · 1 of 3

What happens when a developer on a subscription plan reaches the plan's usage cap?

Choose one answer

The three kinds

  1. Subscription plans. A fixed monthly price with usage caps that reset on a window, such as every few hours or each week. When you hit the cap you wait or upgrade. The worst case is a stalled developer, not a larger bill. Plan details change, so read the vendor's current page.
  2. API billing. You pay for tokens used. There is no cap unless you set one. The worst case is a large invoice.
  3. Rate limits. Requests per minute and tokens per minute, which rise with your usage tier. Hitting one returns an error such as HTTP 429 and the agent retries or stops. This protects the provider's capacity, not your wallet.

How to set controls

  1. Pick the billing model per group. Many teams give regular users a seat plan with caps and put automation, CI agents and power users on the API with a limit.
  2. Set a workspace or organization spend limit. Most API consoles let you set a monthly maximum per workspace. Use separate workspaces for production, CI and experiments, so a runaway script in one cannot spend the budget of another.
  3. Add per-user or per-key budgets where the platform allows it. One key per tool or person also tells you who spent what.
  4. Alert early. Alert at 50, 80 and 100 percent of the limit, to a channel a human reads. A limit with no alert is a sudden outage.
  5. Watch the trend. Export usage and check the daily cost. A jump on one day points to a change, such as a new tool or a retry loop.

Which limit does a heavy user hit first?

Take a developer running an agent all day on a subscription plan. They will hit the plan's usage cap before any spend limit, because the plan has no spend to limit. A CI job on an API key hits the workspace spend limit or a rate limit first, depending on whether it is bursty or steady.

What goes wrong

  • No limit on a key that ships in CI. A loop at 3 a.m. spends the month's budget by morning.
  • One shared key for everyone. You see the total but not the cause.
  • A limit with no alert. The first notice is a failed deploy.
  • Raising the limit to make errors stop. Find why usage grew first.

Examples

A budget setup for a ten-person team

workspaces:
  dev-agents:
    billing: seat plan
    note: caps are per user; no invoice surprise
  ci-agents:
    billing: api
    monthly_limit_usd: 800
    alerts_percent: [50, 80, 100]
    key: one per pipeline
  experiments:
    billing: api
    monthly_limit_usd: 150
    alerts_percent: [80, 100]

The CI workspace has its own limit and one key per pipeline, so a loop in one pipeline is visible by name and cannot touch the experiment budget.

Key points

  • A subscription cap stops the user, a rate limit slows requests, and a spend limit stops the money, so set each on purpose.
  • Use separate workspaces and keys for production, CI and experiments so one runaway job cannot drain every budget.
  • Alert at several thresholds, such as 50, 80 and 100 percent, and send alerts where a human will see them.
  • A heavy subscription user hits the plan's usage cap first, while a CI job on an API key hits a spend or rate limit.
  • When usage jumps, investigate the cause in the usage data before you raise any limit.

Common mistakes

  • Giving the CI agent an API key with no spend limit and no alert.
  • Sharing one key across the whole team so nobody can tell who or what caused a spike.
  • Raising a limit after hitting it, without checking why the usage grew.

Check yourself · 2 of 3

A CI agent on an API key retries a failing step in a loop overnight. Which control caps the damage in dollars?

Choose one answer

Check yourself · 3 of 3

Why give production, CI and experiments separate workspaces?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic