Cutting LLM inference cost and latency without making the feature worse A developer outlined a practical playbook for reducing LLM inference cost and latency without degrading feature quality, centered on per-request cost and latency logging and Anthropic prompt caching. The approach routes every model call through a single wrapper that records route, model, token breakdown, time to first token, total time and computed cost, so teams can attribute spend to features and completed tasks rather than models. The writeup stresses that cache hits require byte-identical prefixes, with stable content (tools, system prompt, reference material) placed before a cache breakpoint and anything variable after it. The first bill for an LLM feature is usually a surprise in one of two directions. Either it is tiny and nobody thinks about it again until usage grows, or it is larger than expected and someone asks for the cheapest model by Friday. Both reactions skip the useful step, which is finding out where the tokens and the seconds actually go. These are the levers I reach for, in roughly the order I pull them. The first ones are close to free. The later ones trade something away, so I only pull them with an eval running next to me. The code uses the Anthropic TypeScript SDK; the ideas apply to any provider with caching and batch pricing. I put this first even though it saves nothing by itself, because every decision after it depends on it. Each model call goes through one wrapper that records the route which product feature made the call , the model, token counts split the way the bill splits them, time to first token, total time and the computed cost. One log line per request is enough to answer most cost questions. llm/cost.ts python import Anthropic from "@anthropic-ai/sdk"; // USD per million tokens, current when I wrote this October 2026 . Keep them in config and // check them against the pricing page. Cache reads bill at about a tenth of the input rate. const PRICE: Record