Course resource
Cost Optimisation Guide
Keeping AI running cheaply, without making it worse.
How the cost is actually made
Most AI pricing is per token — roughly, per fragment of a word, counted on both what you send and what comes back.
Three things drive your bill:
- How often it runs — the filter problem
- How much you send each time — the input problem
- Which model you use — the tier problem
They are in that order deliberately. People optimise the third and ignore the first, which is backwards.
1. How often it runs
The filter is the single biggest lever. An automation running on every email instead of the relevant 5% costs twenty times more than it should, and no amount of prompt tuning fixes that.
- Every trigger has a filter
- The filter runs before any AI step, never after
- Cheap deterministic checks come before expensive AI checks
- Nothing is processed twice — check for a "already handled" flag
- Scheduled workflows do not run when there is nothing new
Bad: Trigger -> AI classifies -> if support, continue
Good: Trigger -> filter to support address -> AI classifies
The first sends everything to the model. The second sends 5%.
2. How much you send
- Truncate long inputs. Most documents do not need their full text for the task.
- Strip boilerplate — navigation, footers, signatures, disclaimers.
- Do not resend the whole conversation when only the last message matters.
- Summarise once, reuse the summary rather than re-processing the source in each step.
- Cap the output.
max_tokensprevents an unexpected essay. - Ask for structured output. JSON is shorter than prose and needs no parsing step.
3. Which model
Match the model to the job, not to the brand.
| Step | Tier | Why |
|---|---|---|
| Classification | cheapest that passes your test set | It is picking from four options |
| Extraction | cheap | Constrained, verifiable |
| Filtering, deduplication | cheap | Or do it without AI at all |
| Drafting for a human | capable | Quality matters, volume is low |
| Final customer-facing output | capable | Worth the money |
| Bulk processing | cheapest that works | Volume multiplies everything |
Test before assuming you need the expensive one. Run your test set against the cheap model. Often it passes, and the saving is an order of magnitude.
The audit
| Workflow | Runs/month | AI calls per run | Model | Cost/run | Monthly |
|---|---|---|---|---|---|
| Total |
Sort by monthly cost. Optimise the top two and ignore the rest — the bottom half of that list is rarely worth your time.
The caps that prevent disasters
- Spending cap set at the provider, where available
- Maximum runs per hour on every trigger
- Maximum iterations on every loop
- Alert at [X]% of the monthly budget
- Alert if daily runs exceed [N]
Calculate the worst case before launch: max cost per run × max possible runs per day × 30. If that figure would be a problem, the caps are too loose.
The things that actually cause bill shocks
No filter. Covered above, and it is almost always this.
A loop without a cap. Retrying forever against a failing API.
A trigger firing more than expected. A webhook that fires on every field change rather than on creation.
Backfill on first run. Connecting to a sheet with 5,000 existing rows and processing all of them.
Someone else's testing. A colleague running the workflow repeatedly to see how it works.
Expensive model on a high-volume step. The classification step running a frontier model 10,000 times a month.
Where not to economise
- Do not skip the human review step to save an AI call. It is not where the cost is.
- Do not remove logging. Debugging without it costs far more than storing it.
- Do not use a model that fails your test set because it is cheaper. Wrong output has a cost too, and it is usually larger.
- Do not remove the error path. Silent failure is more expensive than the notification.
The monthly review
| Month | Total cost | Biggest workflow | Change vs last | What I changed |
|---|---|---|---|---|
Watch for cost rising without volume rising. That usually means a filter stopped working, or a workflow started running on something it should not.
The honest framing
For most individuals, AI costs are small and the optimisation is not worth much of your time. Do the filter properly, pick the right model tier per step, set a cap, and move on.
It becomes worth real attention at volume — thousands of runs a month — or when a single workflow is processing large documents repeatedly. Until then, your time is the expensive resource, not the tokens.