Budgets for agents: calls per hour, tokens per day, dollars per month

A budget limits how many calls an AI agent makes, and how much it spends on models, in each hour, day and month. Here is which limits LumoAuth has, how to set them, how tokens and dollars are counted, and what the agent sees when its budget is spent.

An agent budget in LumoAuth is a set of limits on one AI agent: API calls per hour and per day, model tokens per hour and per day, and dollars per day and per month. LumoAuth counts the agent’s calls itself. It counts tokens and dollars from usage reports, because the agent’s model calls never reach it. When any limit is reached, LumoAuth answers the agent’s next call with 429, until the window ends or you raise the limit.

TL;DR

  • A budget belongs to one agent. It applies across all of the agent’s credentials and tokens, and every limit in it is optional.
  • LumoAuth counts the calls that the agent makes to LumoAuth: permission checks, token requests and just-in-time requests.
  • Token and dollar limits count only reported usage. The agent reports after its model calls, or a component that you trust reports for it.
  • The windows are fixed: each UTC hour, each UTC day and each UTC month.
  • A spent budget does not suspend the agent. LumoAuth answers 429 to the next call that counts, and tokens that the agent already holds stay valid until they expire.
  • The agent can read its limits, its usage and exhausted in UserInfo. If you connect LiteLLM or Portkey, the agent’s key at the gateway gets the cost limit too.

What is an agent budget?

A budget is a list of limits that is stored on the agent’s record. Each limit names a quantity and a window, such as 500 calls per hour or 50 dollars per month. The budget belongs to the agent, not to one credential. An agent that rotates its key, or holds several tokens, still has one count.

A budget is not a rate limit, although both can answer 429:

  Rate limit Agent budget
Protects A service, from too many requests Your organization, from one agent
Applies to An IP address, a client or an endpoint One agent, across all of its credentials
Window Seconds or minutes An hour, a day or a month
Counts Requests Calls, model tokens and dollars
Who sets it The service You, for each agent

The post on capabilities covers what an agent may do. A budget covers how much of it the agent may do.

Why does an agent need a budget?

A person stops when a task goes wrong. An agent often tries again. Suppose that a tool returns an error and the agent’s loop has no step limit. The agent then calls the model again and again, and every call costs tokens. Nobody notices until the invoice arrives.

An attacker can cause the same loop on purpose. With prompt injection, a document or a web page can tell the agent to repeat a task, or to do work for someone else. The agent’s capabilities still limit which actions it may take. They do not limit how often it takes them.

A budget sets that limit in advance. If the agent loops, it can make only a fixed number of calls in an hour. If its model spend passes the monthly limit, its next request to LumoAuth is refused. You choose the worst case before it happens.

Which limits can you set?

A budget has seven limits. Each one is optional, and you can combine them:

Key What it limits Window Where the count comes from
max_api_calls_per_hour Calls to LumoAuth UTC hour LumoAuth counts them
max_api_calls_per_day Calls to LumoAuth UTC day LumoAuth counts them
max_tokens_per_hour Model tokens UTC hour Usage reports
max_tokens_per_day Model tokens UTC day Usage reports
max_cost_per_day_usd Cost in dollars UTC day Usage reports
hard_limit Cost in dollars. In the portal, this is Daily hard limit UTC day Usage reports
max_cost_per_month_usd Cost in dollars UTC month Usage reports

If you leave a limit out, the agent has no limit of that kind. Each value must be greater than zero: a whole number for calls and tokens, and an amount for dollars, such as 50 or 12.5. hard_limit and max_cost_per_day_usd both limit the cost for one day. If you set both, the lower one applies.

The windows are fixed. An hour starts at minute 0, a day starts at 00:00 UTC, and a month starts on its first day at 00:00 UTC. A fixed window has one effect that you should plan for. With 500 calls per hour, an agent can make 500 calls at 10:59 and 500 more at 11:00. Set a daily limit next to the hourly limit, so that a long loop stops too.

A budget can hold two more settings: max_steps and timeout_seconds. In the portal, they are Max steps and Timeout. LumoAuth stores them and returns them to the agent in UserInfo. The agent’s steps run in its own code and never reach LumoAuth, so the agent’s own loop must read these values and stop.

How do you set a budget?

In the portal, go to Agents and choose Register agent. Step 3, What it may do, has the section Budget and limits. It has one field for each limit: Calls per hour, Calls per day, Model tokens per hour, Model tokens per day, Daily hard limit and Monthly cost limit. Two more fields hold Max steps and Timeout. The agent’s edit page has the same section. Leave a field empty for no limit.

In the Admin API, send budgetPolicy when you create the agent or when you change it. This call sets four limits on an agent that exists:

ORG=acme-corp
AGENT_ID=agt_3f9a51c07be24d18
curl -sS -X PATCH "https://app.lumoauth.dev/orgs/$ORG/api/v1/admin/agents/$AGENT_ID" \
  -H "Authorization: ApiKey $LUMOAUTH_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
        "budgetPolicy": {
          "max_api_calls_per_hour": 500,
          "max_api_calls_per_day": 4000,
          "max_tokens_per_day": 2000000,
          "max_cost_per_month_usd": 50
        }
      }'

The organization API key needs the admin:agents:write scope. Four rules apply to a change:

  • The new policy replaces the old one. Send every limit that you want to keep, not only the limit that changes.
  • An empty object removes the budget. Send "budgetPolicy": {}, and the agent has no limits.
  • A new limit applies to the agent’s next call. The counts for the current windows stay as they are.
  • A misspelled key is refused. LumoAuth answers 400, names the key and lists the keys that exist. It stores nothing. A value that is zero, negative or not a number gets the same answer. A limit with a wrong name is therefore never saved as a limit that does nothing.

The response returns the stored policy in budgetPolicy, and so does GET /admin/agents/{agentId}.

The portal and the Admin API change the same policy. A save of the agent’s edit page changes only the limits whose fields you changed. The limits that you set through the Admin API stay as they are.

Which numbers should you choose? LumoAuth counts calls for every agent, also for an agent without limits. Run the agent for a week without limits. Then read its usage on the agent’s edit page or in UserInfo, and set each limit above the highest normal value, with some room.

Which calls count against the budget?

LumoAuth counts the calls that ask it for a decision or a credential. Each call adds one to the count for the hour and one to the count for the day:

  • Permission checks: calls to the Ask API, and tool checks for MCP servers.
  • Token requests: the client credentials grant, token exchange, workload attestation, AAuth platform tokens, tokens from the Token Vault, and tokens that an administrator mints through the Admin API.
  • Just-in-time permissions: each permission request, and each just-in-time token.

Three kinds of call do not count:

  • Reading UserInfo or GET /agents/me. An agent can always check its own budget.
  • Usage reports, which the next section covers.
  • A call that LumoAuth refuses because the budget is spent.

LumoAuth counts and decides in one atomic database statement. With a limit of 500 calls per hour, LumoAuth serves 500 calls and refuses the next one. A burst of parallel calls cannot pass the limit.

The count covers calls to LumoAuth only. Suppose that the agent holds a token and calls your own API with it. That call does not reach LumoAuth. A call limit therefore bounds the number of decisions and new tokens that the agent can obtain. It does not count every request that the agent sends elsewhere.

How do token and dollar limits work?

The agent’s model calls do not reach LumoAuth. They go to the model provider, or to your AI gateway. Token and dollar limits therefore count only the usage that is reported to LumoAuth. Without reports, those limits are never reached.

The agent reports after each model call, or after a few calls, with its own access token:

ORG=acme-corp
curl -sS -X POST "https://app.lumoauth.dev/orgs/$ORG/api/v1/agents/me/usage" \
  -H "Authorization: Bearer $AGENT_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"tokens": 1530, "cost_usd": 0.0042}'

The response confirms the report and returns the budget with the new totals:

{
  "recorded": { "tokens": 1530, "cost_usd": 0.0042 },
  "budget": {
    "max_api_calls_per_hour": 500,
    "max_api_calls_per_day": 4000,
    "max_tokens_per_day": 2000000,
    "max_cost_per_month_usd": 50,
    "api_calls_this_hour": 47,
    "api_calls_today": 310,
    "tokens_used_this_hour": 18230,
    "tokens_used_today": 412530,
    "cost_today_usd": 1.21,
    "cost_this_month_usd": 14.87,
    "exhausted": false
  }
}

tokens is the number of model tokens since the last report, input and output together. cost_usd is the cost in dollars. Send either one, or both. A report is not a call that counts. LumoAuth also accepts a report when the budget is already spent, because the usage has already happened. A token that the agent narrowed with scope cannot report usage. Report with the agent’s full token or with its API key.

An agent that reports its own usage could leave usage out, by mistake or because someone manipulated it. If another component handles the agent’s model calls, let that component report. An AI gateway or an orchestrator can report for the agent through the Admin API:

ORG=acme-corp
AGENT_ID=agt_3f9a51c07be24d18
curl -sS -X POST "https://app.lumoauth.dev/orgs/$ORG/api/v1/admin/agents/$AGENT_ID/usage" \
  -H "Authorization: ApiKey $LUMOAUTH_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"tokens": 1530, "cost_usd": 0.0042}'

The rules are the same, and the response has the same fields under data.

What happens when the budget is spent?

LumoAuth refuses the agent’s next call that counts. Every such call gets the same answer, whether it is a permission check, a token request or a just-in-time request:

HTTP/1.1 429 Too Many Requests
Retry-After: 1050
Content-Type: application/json

{"error": "budget_exceeded", "error_description": "Agent budget exceeded"}

Retry-After holds the number of seconds until the spent window ends. For a limit per hour, that is the next full hour. For a limit per day, it is 00:00 UTC, and for the monthly limit it is the first day of the next month. If more than one limit is reached, the header holds the longest of these times. A token that an administrator mints through the Admin API gets the same code and header, in the error format of that API.

Everything else about the agent stays the same:

  • The agent stays active. It keeps its capabilities and its credentials, and it can still read UserInfo and report usage.
  • Tokens that the agent already holds stay valid until they expire. A budget stops new decisions and new tokens. To stop an agent at once, suspend it. The governance docs describe what a suspension revokes.
  • The refusal ends with the window. A spent hourly limit ends at the next full hour, and a spent daily limit ends at 00:00 UTC. You can also raise the limit, and the agent’s next call is served.

A token limit or a dollar limit works one step later than a call limit. A report that passes the limit is accepted, and the agent’s next call to LumoAuth is refused. LumoAuth cannot stop a model call that goes straight to the provider. Two things close that gap: the agent checks its budget before each model call, and your AI gateway enforces the same cost limit.

When an agent gets this 429, it should stop the task and tell its owner. It should not retry in a loop. The time in Retry-After can be hours or days, so the agent should not sleep until then inside a request either. UserInfo shows which window is spent.

How does the agent check its own budget?

The agent calls UserInfo with its own access token. The response holds the budget in budget_policy:

ORG=acme-corp
curl -sS "https://app.lumoauth.dev/orgs/$ORG/api/v1/oauth/userinfo" \
  -H "Authorization: Bearer $AGENT_ACCESS_TOKEN"
{
  "sub": "agent_agt_3f9a51c07be24d18",
  "name": "Support triage prototype",
  "agent_id": "agt_3f9a51c07be24d18",
  "workload_identity": "client_secret:agt_3f9a51c07be24d18",
  "capabilities": ["tickets:read", "tickets:reply"],
  "budget_policy": {
    "max_api_calls_per_hour": 500,
    "max_api_calls_per_day": 4000,
    "max_tokens_per_day": 2000000,
    "max_cost_per_month_usd": 50,
    "api_calls_this_hour": 47,
    "api_calls_today": 310,
    "tokens_used_this_hour": 18230,
    "tokens_used_today": 412530,
    "cost_today_usd": 1.21,
    "cost_this_month_usd": 14.87,
    "exhausted": false
  },
  "tenant": "acme-corp",
  "identity_type": "agent"
}

budget_policy has three parts. The first part is the limits that are set; a limit without a value is left out. The second part is the usage in the current hour, day and month. The third part is exhausted, which is true when any limit is reached. Reading UserInfo does not count against the budget.

In Python, the lumoauth package (version 1.4.0 or later) wraps the report and the check. This loop checks the budget before each model call and reports the usage after it:

from lumoauth import LumoAuthAgent

# Reads LUMOAUTH_ORG_ID, AGENT_CLIENT_ID and AGENT_CLIENT_SECRET from the environment
agent = LumoAuthAgent()
agent.authenticate()


def run_step(llm, messages):
    if agent.is_budget_exhausted():
        raise RuntimeError("Budget spent: stop the task and tell the owner")

    resp = llm.chat(messages)

    # Token and dollar limits count only what the agent reports.
    agent.report_usage(tokens=resp.usage.total_tokens, cost_usd=0.0042)
    return resp


budget = agent.get_budget_status()
print(budget.get("tokens_used_today", 0), "of", budget.get("max_tokens_per_day", "no limit"))

is_budget_exhausted() reads the copy of the budget that the SDK keeps. report_usage() updates that copy with each report, and get_agent_info() reads the budget from LumoAuth again.

How does the budget reach your AI gateway?

An AI gateway handles the agent’s model calls, so it can refuse a call that would pass a cost limit. If you connect LiteLLM or Portkey, LumoAuth creates one key at the gateway for each new agent. It copies the agent’s cost limit onto that key:

  • max_cost_per_month_usd comes first. LiteLLM starts the count again every 30 days, and Portkey every month.
  • A daily limit comes next, on LiteLLM only. If the agent has no monthly limit, LumoAuth uses max_cost_per_day_usd or hard_limit, and the count starts again every day.
  • Without a cost limit, the key gets the default budget that you set for the gateway.

LumoAuth copies the limit once, when it creates the key. If you change the agent’s limit later, change the key’s budget at the gateway too.

The gateway’s spend does not reach LumoAuth on its own. To count that spend against the agent’s budget, report it through the Admin API, for example from the gateway’s spend callback. The agent’s budget in LumoAuth and its key at the gateway then stop at the same amount.

How LumoAuth does it

In the Organization Portal, go to Agents (/portal/agents) and choose Register agent. Step 3, What it may do, holds the section Budget and limits, with one field for each limit. The review at the end of the step shows the budget before you register the agent. To change the budget later, open the agent’s edit page and use the same section.

On the edit page, the section also shows Usage in the current windows. The table has one row for this hour, one for today and one for this month. Each row shows the calls, the model tokens and the cost, next to the limits. When the budget is spent, the section says so and names the time at which the window ends.

The agent list has a Budget column. It shows the agent’s limits, or Uncapped when none is set. The posture card on the agent’s page has one line for the budget:

Posture line Severity When it appears
Budget is capped OK The agent has at least one limit on calls, model tokens or dollars. It does not matter whether you set the limit in the portal or through the Admin API
No budget ceiling Warning No such limit is set. The line links to Set a budget

Max steps and Timeout alone do not make the line pass, because the agent’s own code applies them and LumoAuth refuses nothing on their account. While a window is spent, the agent’s risk score also includes the factor Budget exhausted, and the agent’s page shows it in the score’s breakdown.

From a script, use the Admin API with an organization API key that has the admin:agents:write scope. The caller also needs the agents.edit permission. LumoAuth records these events in the audit log:

Event When it is written
agent.updated The budget changed, with the old and the new policy
agent.budget_exhausted A call or a usage report spent the budget. LumoAuth writes it once, with the limits that were reached, and not again for each call that it refuses afterwards
jit.budget_exceeded A just-in-time request or a just-in-time token was refused because the budget was spent

The docs for the agent registry cover the budget keys, usage reports and the budget_policy object in UserInfo. The docs for AI gateways show how to connect LiteLLM and Portkey. The governance docs describe the risk score and suspension. This series starts with What is an AI agent identity?, and the previous post covers agent API keys that expire.

Standards involved

  • Additional HTTP status codes, RFC 6585, for the 429 Too Many Requests answer
  • OpenID Connect Core, for the UserInfo endpoint where the agent reads its budget

The full list is on the standards reference.

FAQ

What is the difference between a rate limit and an agent budget? A rate limit protects a service from too many requests in a short time, and it usually applies to an IP address or a client. A budget protects your organization from one agent. It applies to that agent across all of its credentials, over an hour, a day or a month, and it counts calls, model tokens and dollars.

Does LumoAuth see how many model tokens my agent uses? No. The agent’s model calls go to the model provider or to your AI gateway, not to LumoAuth. Token and dollar limits therefore count only the usage that is reported to LumoAuth, by the agent itself or by a component that you trust. Without reports, those limits are never reached.

Does a spent budget suspend the agent? No. The agent stays active, with its capabilities and its credentials. LumoAuth answers 429 to its next calls until the window ends or you raise the limit. Tokens that the agent already holds stay valid until they expire. To stop an agent at once, suspend it.

When does a spent budget start again? At the start of the next window. Hours start at minute 0, days at 00:00 UTC, and months on the first day at 00:00 UTC. You can also raise the limit, and the new limit applies to the agent’s next call.

Can the agent find out how much budget it has left? Yes. The agent calls UserInfo with its own access token. The budget_policy object in the response holds the limits, the usage in the current hour, day and month, and exhausted, which is true when any limit is reached.


Related: AI agent identity on the solutions pages, and capabilities, not scopes on this blog.

Register your first agent at app.lumoauth.dev/register.

Last updated .

Ship passwordless sign-in this week. Put guardrails on your agents today.

The Developer plan is free for 10,000 monthly users and ten agents, with no card. Everything uses open standards, so moving in or out is a config change.