B
BRENDAN O'NEILTC
Brendan O'Neil
TC
PLAYBOOK 04Intermediate30 min

Keep costs under control and pick the right model (Claude, local models, and when to use which)

The research run I estimated at $1 that really cost $5, and the guardrails I built so it can't happen again. Plus when to use a big model, a small one, or one running free on your own machine.

AI is cheap per call and expensive in loops. Everything below comes from real numbers in my own tools.

Understand what you're paying for

API models charge per token, roughly three-quarters of a word, and output costs more than input. Current list prices per million tokens (in / out):

Model Good for In / out
Claude Opus hard reasoning, research, drafting that matters $5 / $25
Claude Sonnet strong everyday work $3 / $15
Claude Haiku fast, simple, high-volume jobs $1 / $5

Check the current pricing page before you build. Prices change, and a cheaper tier often appears.

IGOutput price per million tokens
  • Claude Opus$25
  • Claude Sonnet$15
  • Claude Haiku$5

Output costs 5× input on every tier

Log every call

Before adding features, add a ledger: every model call records its operation, tokens and cost. My usage tab groups spend by day, operation and run, so "what did this morning's refresh cost?" has an exact answer. My last 30 days: $0.26.

Add a token-usage ledger: wrap every model call, record operation name, model, input/output tokens and computed cost. Show a daily total in the UI.

Put a ceiling on it

A hard daily spending limit, enforced in code, that blocks calls once it's hit. Mine defaults to $5 a day, and 0 is a kill switch. Pair it with manual-by-default jobs: nothing runs on a schedule until you've turned it on.

What went wrongI estimated a research run at $0.40–$1.20. It really cost $4.20–$5.62. Five scouts × two rounds, each able to re-trigger up to eight web searches: up to 400 searches in a single run, and my ledger didn't count search fees. Measure the loop, not the call.
IGA research run: estimate against reality (high end)
  • My estimate$0.40 to $1.20
  • What it cost$4.20 to $5.62

Up to 400 web searches in one run

Find the expensive holes

Things that quietly burn money:

  • Retry loops, where a failed call gets sent again and again
  • Tools inside loops, such as web search or browsing, which are billed per use
  • Buttons that skip the cache. I found one that could have cost ~$450 an hour if clicked in a loop, and removed it.
  • Oversized requests that fail. I once sent 200 items in one call, paid ~$0.50, and got zero results back.

Ask Claude to audit for these directly:

Audit this app for cost risks: loops, retries, uncached calls, unauthenticated endpoints that trigger model calls. List each with a worst-case cost.

Use the smallest model that does the job

Labelling news items is simple, so moving it to a smaller model made it 5× cheaper ($0.0029 → $0.00058 per item) with no quality loss I could see. Keep the big model for drafting and research, where quality shows.

Run models locally for free

Ollama runs open models on your own machine, at no per-token cost:

brew install ollama        # or download from ollama.com
ollama pull qwen3.6:35b-a3b
ollama run qwen3.6:35b-a3b "Summarise this in one line: ..."

It also serves an API at http://localhost:11434, so your app can call it like any other model. Answers take about four seconds on a recent Mac once it's warm. The catch: it only works while your machine is on. That's great for development, private data and bulk jobs; not for a public website.

Choose by use

Use Pick
Private data, bulk jobs, experiments Local model (Ollama)
A public widget with light traffic A small hosted model (e.g. Haiku), billed per use
Research and drafting that matter A large model
Anything on a loop The cheapest model that passes your test, with a ceiling

A dedicated cloud GPU for your own model sounds thrifty. At low traffic it's the most expensive option, because you pay for it 24 hours a day, used or not.

Cost checklist

  1. A ledger on every call
  2. A hard daily ceiling in code, plus a kill switch
  3. Manual by default
  4. A cost audit for loops, retries and cache skips
  5. The smallest model per job
  6. Local models for private and bulk work

Next playbookSkills, hooks and automation: make Claude run your pipeline →

Render queue · Job 001● Weekly

Bren Builds

What I built with AI this week, what broke, and what I learned. One email, weekly.

← All builds & playbooks

Built on craft. Powered by code.

End of reel · TC 20:00:00:00