New Tool Radar

AI Agents & Automation

How to Set a Usage Limit on an OpenAI API Project So an Agent Cannot Overspend

Set a spending limit on the OpenAI API project that backs an agent so a looping or busy agent stops at the cap instead of running up a bill.

Schematic diagram with three steps: Open the project limits, Set the monthly cap, then Check the first bill.

An agent that loops, or one that gets busy, can spend far more than a single chat ever would. A usage limit on the API project caps that spend: the project stops making calls at the limit, so the worst case is a stopped agent, not an open bill.

Before you start

You need access to the OpenAI API project that backs the agent, with permission to set its limits. Note the current monthly spend first, so the cap is set from a real number, not a guess.

Set the limit on the project

Open the project limits in the OpenAI platform and set a monthly usage cap that covers normal work with a small margin. Set an alert below the cap, so you hear about heavy use before the cap stops the agent.

Check the first month against the cap

After a month of agent runs, compare the actual spend with the cap. If the agent hit the cap, check the trace for loops or repeated calls before raising it. A cap that is always hit is a sign the agent is wasting calls, not a sign the cap is too low.

Worked example: Cap and spend for a fictional support agent

Maple Support is a fictional support desk. Its agent runs on one API project. The table shows three months.

Month Spend in dollars Cap in dollars Hit the cap?
November 2026 42 100 No
December 2026 58 100 No
January 2027 96 100 No

Expected result (UNTESTED): three months of agent runs stay under the 100-dollar cap, with the highest month at 96 dollars. We checked the OpenAI Agents SDK guides, which describe the SDK and its tracing, but the usage limit itself is set in the OpenAI platform, which we did not open in this task.

Limits

A cap stops the agent when it is hit, which can mean a stopped support agent in the middle of the day. Set the alert well below the cap, and keep a second project for testing so test runs do not eat the production budget.

Sources

See all