Software factory / Start
Cap the monthly model spend
The forge pays for the Workers AI models of your agents and chats. You want to see what it spent this month, and to set a lower cap for your organization.
6 min read
A cap stops this cost at a maximum for each user or organization in a UTC month. After the cap, runs on these models are skipped until the next UTC month, or until you add your own model key.
You need admin access to the repository, or to be an owner of the organization. Only an owner sets a lower cap.
1. See what the forge spent
Open the factory settings. Each factory settings page shows Spent this month: $X of $Y:
- X is what the forge spent this UTC month.
- Y is the cap.
While billing is on, Y can be another cap, or the line can show what billing leaves. See When billing is on.
On a repository page, the line is under Monthly model spend, and the cap of the owner holds. The admins of a repository also see this number in the Spend section of the Agents tab. It is next to what each agent of the repository cost. See See what your agents cost.
2. Set a lower cap for an organization
The owners of an organization can set a lower cap. A repository cannot set a cap.
- Open
/organizations/<org>/factory, the Software factory tab. - Go to the card Rules for all agents.
- Type a whole number of dollars in Monthly spend cap in dollars. It cannot be more than the maximum of the forge. A higher number is refused, and the message names the maximum. While billing is on for the organization, the cap can be up to 100,000 dollars.
- Click Save rules.
To use the maximum of the forge again, empty the field, then click Save rules. While billing is on, an empty field sets no cap of your own, and billing limits the AI.
Done
The forge pays for the models of your organization up to the cap that you set. The settings pages show how much of it is spent.
What counts
Only the models that the forge pays for count: the provider Workers AI. This includes the @cf/... models and the AI Gateway models, such as openai/gpt-6-luna, openai/gpt-6.1-terra and anthropic/claude-haiku-5.5.
- The factory agents, the PR chat and the architecture chat count toward the same cap.
- A model with your own key does not count, and has no cap.
- The Clef calls of the factory do not count either: the first check of the security audit, and the impact check.
The forge counts the tokens of each model call at these prices, in dollars for each 1M tokens:
| Model | Input | Output | Cached input |
|---|---|---|---|
@cf/deepseek-ai/deepseek-v4.1-flash-1017 | $0.30 | $1.20 | $0.006 |
openai/gpt-6-luna | $0.10 | $0.50 | $0.01 |
openai/gpt-6.1-terra | $1.00 | $5.00 | $0.05 |
anthropic/claude-haiku-5.5 | $0.10 | $0.50 | $0.01 |
A long prompt costs more:
- GPT-6 Luna, over 272,000 tokens: $0.20 for each 1M input tokens and $0.75 for each 1M output tokens.
- GPT-6.1 Terra, over 272,000 tokens: $2.00 for each 1M input tokens and $7.50 for each 1M output tokens.
- Claude Haiku 5.5, over 100,000 tokens: $0.50 for each 1M input tokens and $2.50 for each 1M output tokens.
The forge refuses to save a Workers AI model that has no price. The runs list shows the cost in dollars of each run on a model that the forge pays for. See Factory runs.
The maximum of the forge
Each user and organization has a maximum. The first of these that is set holds:
- The cap of the account, when a site admin gave the account its own limits. See Give one account higher limits.
- The cap of the site, that a site admin sets on Admin > Limits. See CI and AI.
- The variable
FACTORY_MONTHLY_SPEND_CAP_USDof the deploy. The person who runs the deploy sets it. This deploy sets 3 dollars. - 50 dollars, when the variable is missing or is not a number above 0.
A personal account always gets this cap.
At the cap
- A new run on a model that the forge pays for is skipped with "Monthly model spend cap reached".
- A run that is going stops with "The run used the money left of the monthly model spend cap."
- The PR chat and the architecture chat answer that the owner used its monthly model spend for the forge's models.
Runs that go at the same time can go a little over the cap. The cap starts again at 00:00 UTC on the first day of the month.
When billing is on
A site admin can turn on billing. Then the plan of the owner pays for the models that the forge pays for:
- The forge-paid AI of the plan pays first, then the credits, then the overage. See Know what pays when the plan is used up.
- The cap of the site and the variable of the deploy do not hold.
- The cap that a site admin gave the account still holds, and so does the cap of an organization. This cap can be up to 100,000 dollars.
- When nothing is left, a new run is skipped with No AI left this month. A run that is going stops with the same badge.
- The chats answer that there is no AI left this month.
The caps count the cost to the forge, and the plan counts AI at 1.5 times this cost.
The line Spent this month shows what limits the AI of the account:
- A cap holds: the cap that a site admin gave the account, or the cap of an organization. The line shows Spent this month: $X of $Y, and Y is this cap. The plan can stop the AI before X reaches Y. To see what is left of the plan, open the Billing page.
- No cap holds: the line shows Spent this month: $X. Billing pays for forge-paid AI: $L left this period. L is what the plan, the credits and the overage leave in this billing period, at 1.5 times the cost to the forge. The link Open the billing page goes to the Billing page of the owner. On a repository of another person, the line has no link: the Billing page of a person is for that person only.
Billing is off for an account that a site admin made exempt. Its line shows the same cap as while billing is off.
The limits of one run
A built-in agent has no token budget. Three limits stop a run:
- The monthly spend cap.
- At most 100 model calls in one run of a built-in agent.
- The time limit. Architecture and the steps of PR summary stop after 15 minutes. Every other step stops after 2 hours. An agent with tools also stops when its model call sends nothing for 5 minutes.