LLM cost anti-patterns
The 21 patterns the cost audit looks for in code that calls a language model. Each page explains how the pattern turns into money, shows an example, and gives the fix.
- No spend cap on LLM callsNo dollar or token cap anywhere on the path to a paid call.
no-budget-guard - Rate limiter that only exists when env vars are setA spending or abuse guard that only exists when certain env vars are set.
guard-conditional-on-env - LLM call with no output token limitA call with no output cap on a model where long answers are expensive.
no-max-tokens - Frontier model used for a short, simple taskA frontier model doing a short, simple job where a cheaper sibling is likely enough.
model-oversized - Agent loop with no iteration limitAn agent or tool loop with no iteration limit.
agent-loop-unbounded - Retries on a paid call with no cap or backoffRetries on a paid call with no cap, no backoff, or both.
retry-storm - Async generation job polled with no deadline or cancelA billable job polled with no deadline and no way to cancel it.
orphaned-async-job - Full chat history re-sent on every turnThe whole conversation re-sent on every turn, so cost grows with its square.
full-history-resend - Scheduled job that calls a model on a timerA scheduled job that calls a model whether or not anyone is using the app.
recurring-job-llm - Images sent to a model in a loop at full resolutionImage or vision calls inside a loop with no limit on how many.
vision-in-loop-uncapped - High reasoning budget on a call that runs many timesA high reasoning budget on a call that runs many times.
reasoning-budget-in-loop - One request that triggers many model callsExtra model calls (moderation, titles, summaries) multiplying every request.
auxiliary-call-multiplication - Gemini context cache created and never deletedProvider-side caches created and never deleted, billed by the hour.
cache-storage-leak - Prompt cache breakpoint on text that changes every callPrompt caching on text that changes every call, so you pay to write and never read.
cache-write-churn - Same deterministic call paid for on every requestThe same deterministic call paid for again on every duplicate request.
result-cache-candidate - Bulk work sent one call at a timeBulk work sent one call at a time where a batch API costs half.
sync-batch-candidate - Fallback model that never switches backA fallback to a pricier model that never switches back.
sticky-fallback-model - Request fields passed to a paid call without validationRequest fields reaching a paid call with no validation.
unvalidated-input-to-paid-call - Public endpoint that spends your model budgetAn endpoint anyone can call that spends your model budget.
unauthenticated-llm-endpoint - LLM API key shipped to the browserA provider key shipped to the browser.
client-side-key-exposure - Provider API key committed in sourceA provider key committed in source. The key is masked in every report.
hardcoded-api-key