Skip to content
NEWNano Banana 2.1 is live — Google's latest image model, from $0.0336 per image, native 4K, about half the price of the previous generationView model
HopBase
← Back to blog

LLM API Budget Limits for Teams: Stop AI Overspend | HopBase

You keep an LLM API budget under control by enforcing limits before the bill arrives: give every department and every member a monthly budget, give every automated service its own key with a hard cap, and let the platform reject requests once a limit is hit. On HopBase, a request over its limit is rejected before it is processed (HTTP 402 insufficient_quota), so a runaway agent loop stops at its cap instead of draining the month. Department and member budgets reset together on a billing day you choose (the 1st to the 28th of each month), the company balance can carry several alert tiers that send email and in-app notices, and two cost levers (picking a cheaper model per task and using prompt caching) lower the unit price. A 15-minute weekly review with the CSV export closes the loop.

Why AI spend overshoots

  • Token billing scales with traffic. There is no flat fee. A new feature or a bad retry loop can double spend within hours.
  • Automation runs unattended. Agents, batch jobs and cron tasks run overnight. A loop without an exit condition keeps calling.
  • Shared keys hide ownership. When one key serves five projects, nobody can say who spent what.
  • Flagship models everywhere. Using the top model for classification or extraction turns a price gap into a budget gap.

So the goal is concrete: every request has an owner, every owner has a limit, and the system enforces the limit automatically, with no one watching dashboards all day.

Step 1: Set up three levels of limits

In a HopBase enterprise account, the owner (or an enterprise admin) creates members and departments, and all usage is charged to the company balance. Limits work at three levels:

LevelWhat it capsResetBest for
Department budgetMonthly spend of the whole department, including its members and keysOn the billing dayFinance budgeting by cost center
Member budgetMonthly spend of one personOn the billing dayEngineers, analysts, support staff
Key capTotal spend allowed on one keyAdjusted manuallyAgents, batch jobs, production services

Three rules worth knowing up front:

  1. Member budgets may add up to more than the department budget. In that case it is first come, first served: once the department budget is used, every request in that department is rejected.
  2. Department heads receive budget alerts for their department and its members, and can manage those members (add, edit, remove, set budgets, disable, change groups). They cannot change the department budget, billing day or the head role itself; the owner or an enterprise admin sets those.
  3. Keys not tied to a member can belong directly to a department, so service spend counts against that department's budget.

Step 2: Give every automated service a capped key

The most common gap in team LLM API budget limits is machines. Give each service its own key and set these at creation:

  • Cap: about 1.5 to 2 times the service's normal spend. Enough headroom for spikes, low enough to stop a runaway.
  • Groups: each key holds 1 to 10 groups and can only call models in them. Give a batch-job key only the groups with lighter models, and a bug cannot reach a flagship model.
  • Expiry, IP list, concurrency: set an expiry for one-off jobs, lock production keys to your egress IPs, and use a concurrency limit to absorb bursts.

When a key reaches its cap, the next request returns 402 before any processing, so nothing is generated and nothing is charged. Treat 402 as a stop signal, not a reason to retry:

from openai import OpenAI, APIStatusError

client = OpenAI(api_key="sk-your-key", base_url="https://api.hop-base.com/v1")

def step(messages):
    try:
        return client.chat.completions.create(model="your-model", messages=messages)
    except APIStatusError as e:
        if e.status_code == 402:  # insufficient_quota: cap reached
            raise SystemExit("Key cap reached: stop the agent loop and alert the owner")
        raise

For an emergency stop, disable or revoke the key in the console. It takes effect immediately.

Step 3: Balance alert tiers and the billing-day reset

Budgets control who can spend how much; balance alerts tell you how much the company has left. Set several thresholds on the available balance, for example "two weeks left", "one week left" and "three days left". Each time the balance drops below a tier, you get an email and an in-app notice, so top-ups are planned instead of discovered when every request returns 402.

Align the billing day with your finance month-end (any day from the 1st to the 28th). On that day, department and member budgets reset together and the new month starts from zero.

Step 4: Two levers that lower the unit cost

  1. Match the model to the task. Use light models for classification, rewriting and extraction; keep flagship models for hard reasoning and code. HopBase bills at each vendor's official list price times the group discount, and the same model can carry different discounts in different groups. See the group routing cost guide.
  2. Use prompt caching. When long system prompts, documents or chat history prefixes hit the cache, they are billed at the vendor's cache-read price, which is usually far below the normal input price. See the prompt caching cost guide.

Step 5: A 15-minute weekly review

  1. Open the usage page, select the last 7 days and export the CSV. Filter by key, member, department or key creator; one file holds up to 50,000 rows and a range of up to 400 days.
  2. Sort by charged amount. Compare the top 5 keys and top 5 models with last week.
  3. Spot-check a few rows: official cost × discount ÷ exchange rate = charged amount. Failed requests are not billed.
  4. For a key that jumped, ask its creator why. Lower the cap or move it to a cheaper group if needed.
  5. Review alerts. If the same tier fires several times in a week, adjust budgets or your top-up rhythm.

For row-by-row reconciliation and chargeback, see LLM API usage reconciliation and department chargeback.

Worked example: a 30-person company (hypothetical numbers)

All figures below are invented for illustration. They do not describe any real customer and are not HopBase prices.

ItemExample limit (USD/month)Notes
Engineering1,8008 engineers at 200 each (1,600 total), plus 2 service keys
Engineering · code-review agent key150Light-model groups only; locked to the CI egress IP
Support7004 members at 200 each (800 > 700, first come, first served)
Marketing3002 members at 150 each
Balance alerts1,500 / 800 / 300Email when the available balance drops below each tier

Suppose a parsing bug sends the code-review agent into a loop. It keeps calling until the key's 150 cap is used, then every request returns 402. Other engineers keep working, the department head gets a budget alert, and the key tops the list at the next weekly review. The damage is capped at 150.

FAQ

How do I set LLM API budget limits for my team?

Do three things: give each department and member a monthly budget, give each automated service its own capped key, and set at least two alert tiers on the company balance. With those in place, one broken script cannot spend the whole month's budget.

What happens when a budget runs out? Am I charged first?

No. The request is rejected before it is processed with HTTP 402 insufficient_quota, and nothing is charged. Failed requests are not billed either. Raise the limit, or wait for the billing-day reset, to continue.

Do team AI budgets reset every month automatically?

Yes. Member and department budgets are monthly and reset on the billing day you set (the 1st to the 28th). A key cap is a per-key ceiling that you adjust manually.

To set this up for your team, create a HopBase enterprise account, add departments and budgets, and issue keys in a few minutes.