Workers AI runaway bills: how agent loops and retries add up
Workers AI bills in neurons. An agent loop or a retry that re-runs inference can spend more in an hour than your traffic does in a month.
Workers AI bills in neurons, $0.011 per 1,000, after a daily free allowance of 10,000. A million neurons is $11. How many neurons a call uses depends on the model and the tokens, so check the pricing page for yours.
In my experience the scary case isn't traffic. It's a loop. An agent that calls the model, doesn't like the answer, and calls it again. Or a queue consumer that runs inference, throws after, and retries the whole thing. Each retry pays for inference again.
Some cheap guards
- Put a hard max on agent steps per request. Like, a literal counter.
- Set
max_tokens. Don't let the model decide how long to ramble. - Save the model output before the step that can fail, so a retry doesn't redo inference.
One annoying detail: Workers AI analytics don't say which script made the call. So workerfuse charges all Workers AI usage to every script with an AI binding. That overcounts if you have several, but I'd rather pause early than not at all.