Pricing and running AI products
How do you cut LLM costs without making the product worse?
Cal Renshaw, , 1 minute read
Take every job out of the model that you could write as a rule before seeing the input, and do it in ordinary code. Totals, sorts, date checks, formats, duplicates. It's the first saving to make, because it makes the product cheaper and more exact at the same time.
5 instructions, 2 of them arithmetic
One Sunday I was reading the instructions my document product sends to the model, all 5 of them, because I wanted to change the wording of one. The product read each document, found the details, checked the names, totalled the figures, and checked every date fell inside the month. 5 steps, 5 paid calls, every document, every month.
The fourth instruction asked the model to add up a column of figures. A language model is extraordinary at reading a messy page and pulling out what matters. It's a slow, expensive and slightly unreliable way to add up numbers. It produces text that looks like a total, and nearly always it's right, and sometimes it's a few pence out. (A few pence is a long way out, in an accountant's spreadsheet.)
The fifth was a date comparison. Ordinary code does that in a line, instantly, exactly, for nothing.
Why it was there
I'd written both instructions in the product's first week, because the model was already reading the document and it was easier to ask it for one more thing. (It always is. That's how these things start.)
I moved both into code over one Sunday. Model spend roughly halved without touching a prompt, and the totals stopped being occasionally wrong.
The test
Read every instruction you send to a model. If it contains a number, a comparison, a sort or a format, ask: could I write the right answer as a rule before I see the input? If yes, it belongs in code. Do that before switching models or trimming prompts.
Who Pays for the AI? has the chapter. Ship Alone tells the same Sunday from the building side.
Questions
- What is the easiest way to reduce LLM API costs?
- Move deterministic jobs, like totals, date checks and duplicate detection, out of the model and into ordinary code.
- Should an LLM do maths in my product?
- No. Let it read and extract. Let code add up, compare and sort.
- Does cutting model calls make the product worse?
- Not when the calls were doing rule-based work. Code is more exact at it, so it often gets better.