FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

Switching to a cheaper model should be your last LLM cost cut

Build an eval, then trim tokens: OpenAI says halving output tokens can cut latency by about half.

ShareLinkedInFacebookX

In brief

  • Get the prompt working before optimizing, because optimizing early can hide the best quality the task can reach.
  • Trimming output tokens and caching the fixed part of the prompt are cheap, low-risk levers to pull first.
  • Move to a smaller model only once you have an eval, and send work to the Batch API only when nobody is waiting for the result.
Big-number chart: with prompt caching, input cost is 35,500 input price units, against 204,000 units without a cache. The example is 20 queries within 5 minutes, each sharing a fixed 10,000-token prompt. Two horizontal bars are drawn to scale, with the cached bar five times shorter.
In the article's worked example, with 20 queries sharing a fixed 10,000-token prompt, Anthropic's cache cuts input cost from 204,000 to 35,500 units. Source: calculation based on Anthropic's prompt caching pricing (cache write 1.25x, cache read 0.1x the input price).

Two lines from the head of operations can change an FDE’s third week at a client: staff say they wait too long, and this month’s API bill is far over the estimate. In this hypothetical case, the internal policy assistant already answers correctly and the business team is happy with it.

Many engineers would immediately switch to a smaller model. That can be the right move, but it often comes at the wrong point in the sequence. Four levers reduce latency and cost, each with its own price, and a good FDE knows which to pull first.

Clients notice this skill more than any other once the demo phase is over. A system that is correct but slow and expensive will struggle to get through budget review, however good its quality.

Why get it right before making it fast?

Anthropic’s documentation is direct: first design a prompt that works well without model or prompt constraints, then apply latency reduction strategies. Optimizing too early can hide the best quality the task can reach.

Before optimizing, then, you need a small eval set, such as a few dozen real client questions with the answers you want. Without it, you cannot tell whether a change that makes the system faster is quietly making it wrong.

Four levers, each with a different effect

The first lever is fewer tokens. According to Anthropic, the fewer tokens a model has to process and generate, the faster it responds. OpenAI offers a memorable rule of thumb: cutting output tokens by 50% can cut latency by about 50%. Ask for shorter, structured answers and set max_tokens as a backstop.

The second lever is prompt caching. When the start of a prompt repeats across calls, the provider stores the part it has already processed, reducing both time and cost. At Anthropic, tokens read from the cache cost 0.1 times the base input price; OpenAI says cached input tokens are discounted by up to 95%.

The third lever is choosing the right model. Anthropic calls this one of the most direct ways to reduce latency, while OpenAI notes that smaller models usually run both faster and cheaper. The trade-off is that, of the four levers, this is the one most likely to lower quality if you switch without checking.

The fourth lever is OpenAI’s Batch API: it cuts costs by 50%, and in exchange each batch completes within 24 hours, often sooner. It suits only work that needs no immediate response, and its rate limits are separate from the per-model limits.

Streaming is not one of the four, because it reduces neither total time nor cost. It works on perception: users see text appear in real time, so the application feels much faster.

A worked example: the policy assistant

Return to the assistant above. Suppose each request contains 10,000 fixed tokens (system instructions plus policy documents) and a 200-token question. At peak, 20 questions fall within the same 5-minute window.

Without caching, you pay for 20 × 10,200 = 204,000 input price units. With caching on Anthropic, the first call writes 10,000 tokens to the cache at 1.25 times the price, or 12,500 units.

The next nineteen calls read from the cache at 0.1 times the price: 19 × 1,000 = 19,000 units. Add 4,000 units for the questions and the total is 35,500, less than a fifth of the original figure.

To get that number, the prompt must be ordered correctly. OpenAI requires the entire prefix to match before the cache can be reused, and advises putting stable instructions and shared reference material first. The layout should look like this:

[1] System instructions  (fixed)
[2] Policy documents     (fixed)
---- end of cached part ----
[3] User question        (changes)

Output comes next. If answers average 400 tokens but users need only the conclusion and the clause it cites, asking for a concise format of about 200 tokens can cut generation time by nearly half, by OpenAI’s rule of thumb.

Summarizing the day’s questions for the business team is different: nobody sits waiting for it. This kind of work is well suited to the Batch API, which halves the cost without touching the rate limits of the live assistant.

The order to follow

The ordering principle is to pull the levers that pose little risk to quality first, and leave those that need an eval to justify them until later. The table has six steps because, besides the four levers, it starts with setting a baseline and slots in streaming midway as a nearly risk-free lever on perception.

Step What to do What it reduces Condition
1 Get the prompt working, build an eval Nothing yet; sets the baseline You have real client questions
2 Trim output tokens, set max_tokens Latency and cost Short answers still cover what matters
3 Cache the fixed part of the prompt Input cost and processing time Stable prefix, steady traffic
4 Turn on streaming (a lever on perception) Perceived latency, not cost A user is waiting
5 Switch to a smaller model Latency and cost Eval results do not drop
6 Send non-urgent work to batch Cost A wait of up to 24 hours is acceptable

Mistakes that make optimization backfire

The most common mistake is breaking the cache without realizing it. Insert the current date and time or the user’s name in the first line of the prompt and the prefix no longer matches, so every request is processed from scratch.

The second is turning on caching for sparse traffic. Anthropic’s default TTL is 5 minutes; if requests arrive further apart than that, every call pays the 1.25x write price without a single read, which costs more than no cache at all. The 1-hour TTL costs 2x to write and is worthwhile only when you are sure of many reads.

The third is treating streaming as a way to reduce total time, then using it in a backend pipeline that waits for the full result. Nobody is watching the text appear there, so streaming adds nothing.

The fourth is changing models on the strength of a few manual tries. A small model may handle ten questions you thought up yet fail on the very type the client asks most. Nor should you move tasks with users waiting to batch just because it costs half as much.

OpenAI adds a principle that is easy to forget: do not default to an LLM. If a step only extracts a contract number in a fixed format, a regular expression is faster and costs nothing.

Clients rarely remember which model you used; they remember that the system answered faster and the bill fell without a loss of quality. When this work goes on your résumé, state the measured result and how you verified it, along the lines of “reduced input costs by reordering the prompt to hit the cache, verified with an eval.”

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
5 sources
Read next on the roadmap · Stage 5: DeploymentSandboxing an agent: file and network fences must go togetherThe more freely an agent runs commands on a client's machine, the more it needs a fence it cannot talk its way past.