Skip to content

OpenAI adds spending limits to individual AI agent sessions

News
A gold budget dial on a cobalt-blue server panel illustrates spending limits for individual OpenAI agent sessions
OpenAI now lets developers set a spending limit for each Agents API session. Editorial illustration.
OpenAI now lets developers set a spending limit for each AI agent session. They can see how much of the budget the job has used. The bill can still go over the limit if cost data comes in late.
The change came to the JavaScript SDK and Python SDK on November 23. An app that uses OpenAI's Agents API can set one budget for a quick task and a larger one for a long job.

What the agent budget tracks

The app sets the limit in US cents with a field called spend_control.limit. A value of 500 gives the job $5 to spend. The API also shows how much OpenAI has counted so far. It rounds the figure down to whole cents. When it has no usable figure, it sends back a null value.
The limit covers the whole session. A chat that takes several turns can draw from the same budget each time. If a team wants to add $3 to a $5 cap, it sets the new total to $8.
A team can set the cap at the start or change it while the job runs. The app can read back the limit and spend. The spend can change each time it checks. If the app leaves the limit off, the session has no cap of its own.

What happens when the agent hits its limit

Once the API sees the agent has hit the cap, it stops taking new input. OpenAI's guide to session budgets lists an event that apps can use to tell people why their work paused. It also lists an error code for a turn the cap stopped.
The limit is best effort. Work the agent has started can still add to the bill. The job can also go on if the API cannot get a cost figure. A team may want to leave room for these extra charges when it sets a cap.
Some tools can add costs on their own bills. An app might call a paid service to look up a fact or store a file. If those costs come from a separate bill, track them alongside the spend that OpenAI reports.

How to restart work after a pause

A developer can raise the cap or take it off. OpenAI says an agent may pick up the task on its own once the limit changes. The app can check what the session is doing before it sends more input. That helps it avoid extra work if a user clicks Retry.
For example, a research app could set a small budget for each report. If it hits the cap, the app could show the cost so far and the notes the agent has saved. A reviewer could pay for the rest or work from those notes.
If the same kind of work hits its cap often, look at where it stops. That may reveal a step that costs more than the team thought. The logs can help decide which jobs get more money and which should be split into smaller tasks.
loading

Loading