Most LLM bills are not high because AI is expensive. They are high because of a handful of defaults nobody questioned: the biggest model for every request, answers with no length limit, the whole chat history resent on every turn, and the same question answered from scratch a hundred times a day.

I priced one realistic workload with current list prices, then applied seven fixes one by one. Every number below comes from arithmetic you can rerun.

The workload

A doubt-solving assistant for a college course. Students ask questions, the bot answers using the course notes.

  • 1,000 questions a day, about 30,000 a month
  • Each request: a 4,000-token system prompt (instructions + course notes), the conversation so far, and a 150-token question
  • Answers average 600 tokens (nobody set a limit)
  • Conversations run about 6 turns

Prices are OpenAI list prices per 1M tokens (December 2026):

Model Input Cached input Output
GPT-5.5 $5.00 $0.50 $30.00
GPT-5.4 mini $0.75 $0.075 $4.50
# Prices per 1M tokens: (input, cached_input, output) GPT_55 = (5.00, 0.50, 30.00) GPT_MINI = (0.75, 0.075, 4.50) def request_cost(price, prefix, rest, out, cache_hit=0.0): inp, cached, outp = price prefix_cost = prefix * (cache_hit * cached + (1 - cache_hit) * inp) return (prefix_cost + rest * inp + out * outp) / 1_000_000 # Baseline: 4,000 prefix + 1,875 avg history + 150 question, 600 out per_request = request_cost(GPT_55, prefix=4000, rest=1875 + 150, out=600) print(per_request * 30_000) # => 1443.75 dollars per month 

The result first

Step Monthly cost Change
Baseline: GPT-5.5 for everything $1,444 —
Fix 1: Route 90% to GPT-5.4 mini $339 −77%
Fix 2: Cap answers at ~250 tokens $234 −31%
Fix 3: Prompt caching (80% hits) $133 −43%
Fix 4: Keep only the last 2 turns $119 −11%
Fix 6: Serve 25% repeats from Redis $89 −25%

Same workload, the big model still answers the hard questions, about 94% cheaper. Fixes 5 and 7 are measured separately because they apply to different kinds of requests.

Fix 1: Stop using the flagship model for everything

GPT-5.5 costs 6.7× more than GPT-5.4 mini for both input and output. Most student questions ("what is overfitting", "list vs tuple") don't need a frontier model. Default to the small model and escalate only when needed.

HARD_SIGNALS = ("prove", "derive", "debug this", "time complexity", "why does this code", "step by step solution") def pick_model(question: str, attached_code: bool) -> str: q = question.lower() if attached_code and len(q) > 300: return "gpt-5.5" if any(signal in q for signal in HARD_SIGNALS): return "gpt-5.5" return "gpt-5.4-mini" 

A keyword router is crude, and that's fine as a start. The important part is logging which model answered and sampling small-model answers every week. Route up only where it actually fails.

Fix 2: Cap the answer length

Output tokens cost 6× more than input tokens on both models. Set a hard limit in the API call and a soft limit in the prompt, so the model plans a short answer instead of getting cut off.

response = client.responses.create( model=model, instructions=SYSTEM_PROMPT + "\nAnswer in at most 150 words unless asked for more.", input=question, max_output_tokens=400, # hard ceiling, rarely reached ) 

Shorter answers also shrink the history you resend next turn. $339 → $234.

Fix 3: Put the stable part first and let the cache work

Every request starts with the same 4,000 tokens. On OpenAI's current models, cached input costs 10% of normal input. Anthropic's cache reads are also about 0.1× base input on most models, with cache writes at 1.25× for the default 5-minute cache.

The catch: caching matches the beginning of the prompt. Put anything variable first and you get zero hits.

# Cache-hostile: first line changes every request prompt = f"""Today is {today}. Student: {student_name}. {INSTRUCTIONS} {COURSE_NOTES} Question: {question}""" # Cache-friendly: identical first 4,000 tokens every time prompt = f"""{INSTRUCTIONS} {COURSE_NOTES} Today is {today}. Student: {student_name}. Question: {question}""" 

At 80% cache hits: $234 → $133. Check the usage object in the response to confirm cached tokens are actually being reported.

Fix 4: Stop resending the entire conversation

Chat APIs are stateless, so every turn resends everything before it. Most doubt-solving questions only need the last exchange or two.

MAX_TURNS = 2 # one turn = one question + one answer def build_messages(history, question): recent = history[-MAX_TURNS * 2:] return recent + [{"role": "user", "content": question}] 

Average history drops from 1,000 to 600 tokens per request. $133 → $119. In long-session products (coding agents, tutoring), this is often the biggest fix of all.

Fix 5: Send data in compact formats

I counted tokens for a 50-row table of student records with OpenAI's cl100k_base tokenizer (newer models use a different tokenizer, but the ratios hold):

Format Tokens Change
Pretty-printed JSON 2,445 —
Minified JSON 1,495 −39%
CSV 870 −64%
Wordy system prompt 139 —
Tight system prompt (same rules) 36 −74%

103 tokens saved on a system prompt looks tiny. At 30,000 requests a month, it's 3.1 million input tokens you no longer pay for.

Fix 6: Never pay twice for the same answer

Before exams, the same questions arrive again and again. An exact-match cache removes those calls completely.

import hashlib, json, redis r = redis.Redis.from_url(REDIS_URL) def normalize(q: str) -> str: return " ".join(q.strip().lower().split()) def cached_answer(question: str, course_id: str): key = "ans:" + hashlib.sha256( f"{course_id}|{normalize(question)}".encode() ).hexdigest() if (hit := r.get(key)) is not None: return json.loads(hit) # cost: $0 answer = ask_llm(question) r.set(key, json.dumps(answer), ex=7 * 24 * 3600) return answer 

Only cache answers that don't depend on who asked. "What is backpropagation?" is safe to share. "Why did my code fail?" is not. $119 → $89.

Fix 7: Batch everything that can wait

OpenAI and Anthropic both offer a Batch API: asynchronous processing, usually within 24 hours, at 50% off input and output.

Grading 5,000 submissions on GPT-5.4 (2,000 input + 300 output tokens each): $47.50 normally, $23.75 with batch. Same model, same prompt, same quality.

Checklist

  • Log model, input, cached and output tokens for every request, per feature
  • Default to the smallest model that passes your quality checks
  • Stable content first in the prompt, variable details last
  • max_output_tokens on every call
  • A hard monthly spending limit with an alert at 50%

Originally published on ZeroAPI, where I write about practical engineering for students and developers. If you want to practise spotting bugs like these, try the BreakIt challenges.