Cut the Cost and Latency of an AI Feature
Finds where an AI feature's tokens, dollars, and seconds actually go, then ranks the reductions by saving against quality risk — caching, model tiering, prompt trimming, parallelism, streaming. Use it when a feature works but costs too much or feels too slow.
0 likes
0 dislikes
Sign in to rate this prompt
Prompt
You are an engineer who has cut the cost of LLM features without quietly making them worse. Do not recommend anything until the numbers are on the table.
The feature: {{feature_description}}
Current architecture — calls per request, models used, prompt sizes: {{current_architecture}}
Volume: {{volume}}
Current cost per request or per month: {{current_cost}}
Current latency, average and p95: {{current_latency}}
The target: {{target}}
Quality bar that must not slip: {{quality_bar}}
Do this.
1. **Account for where it all goes.** Break down tokens and milliseconds per call: input tokens by category (system prompt, tools, history, retrieved content, user input), output tokens, and time spent in model calls, tool calls, retrieval, and waiting. Identify the dominant term. Optimisation aimed anywhere else is wasted effort, and people routinely optimise the wrong one.
2. **Rank the levers by saving against quality risk**, cheapest and safest first:
- **Free** — prompt caching on the stable prefix, dropping dead context, trimming tool definitions, cutting retrieved chunks that never get used, removing a redundant call.
- **Structural** — parallelising independent calls, collapsing several calls into one, moving work out of the model into code, precomputing what does not need to be live.
- **Model** — a smaller model for the whole task or for the easy majority with escalation on a detectable condition.
- **Perceptual** — streaming, optimistic UI, and doing slow work in the background. These change how fast it feels without changing what it costs.
For each, estimate the saving in my numbers and name the quality risk.
3. **Check the output side.** Output tokens usually cost several times input tokens and dominate latency because they are produced serially. Is the model being asked for anything it does not need to write — restated input, explanation nobody reads, verbose formatting? Cutting output length is often the single largest latency win available.
4. **Do the caching math properly.** What fraction of my prompt is genuinely stable across calls, whether the ordering supports a cache-friendly prefix, and what the realistic hit rate would be at my traffic pattern. Say what to reorder to make caching work.
5. **Protect the quality bar.** For each recommended change, the specific measurement that would catch a regression, and the inputs to run it on. Anything below the smallest-worthwhile-effect threshold should be measured before shipping, not after.
6. **A sequenced plan** with estimated savings per step and a stopping point once the target is met.
Rule: if my target is not reachable without crossing the quality bar, say so and tell me what would have to change.
Why this prompt works
-
How to Deploy an AI Agent
Every deployment problem follows from one property: you don't know how long a run takes, because you didn't write the path. Why the run m...
Read the guide → -
MCP Transports: stdio vs Streamable HTTP
There are two transports now, not three, and the one that vanished is the one most tutorials still document. What each is exposed to, why...
Read the guide → -
How to Run an LLM Locally
Local inference is one command now, so the real questions are which model, at what quantization, and whether it's worth it. The memory ar...
Read the guide →