Skip to main content
Use the objective from Step 1 and the spending baseline from Step 2 to evaluate a concrete change. The aim is to learn whether a candidate improves the chosen outcome within your quality and latency limits. A cheaper model, shorter prompt, or different setting is a hypothesis until you have measured it on the workload you serve.

Choose a bounded experiment

Pick a feature with a clear owner and enough recorded usage to explain its current cost. State the suspected cause and the change to test. For email routing, a hypothesis might be that repetitive formatting instructions consume input tokens without improving classification. For an agent, excessive retries might be the more important issue. Change one factor at a time for the first comparison so you can interpret the result. Save the baseline model version, prompt, provider, settings, and rate snapshot. Later, you can evaluate combined changes as a complete configuration, but do not attribute their savings to one component without separate evidence. Build a held-out evaluation set from representative task inputs. Include common requests, long inputs, ambiguous cases, and costly error categories. Keep tuning examples separate from final evaluation examples. Choose the sample size and review depth based on the variation in your traffic and the consequences of mistakes; a handful of successful demonstrations cannot establish a production failure rate.

Optimize your prompt first

Prompt changes are a useful starting point when the baseline shows repeated context or unnecessarily long answers. Specify the result your downstream code needs. For a classifier, an explicit set of categories and a small output schema can make responses easier to validate than an open-ended request for an explanation. Remove instructions only when you understand their purpose. A concise prompt that drops an escalation rule can save tokens while creating expensive mistakes. Test formatting and parsing as part of quality, and count any repair call or fallback in the candidate’s total cost. The prompt-engineering case study illustrates how to separate a shorter-input estimate from reported workload results. If output length dominates cost, test a suitable output limit and inspect truncated responses. A limit caps generation; it does not guarantee a complete answer within that limit. Check the provider’s supported parameters instead of assuming every model accepts the same ranges or settings.

Test different models

Use public benchmark results and capability documentation to form a shortlist, then evaluate those candidates on your own task. A general benchmark can provide useful context, but it cannot establish performance on your prompts, languages, output schema, or operational constraints. Start with a fixed-token rate comparison to screen candidates. Then run each candidate and record its actual usage. The same input text may tokenize differently, and some models produce more output or reasoning tokens. Sum all calls required to complete the task rather than multiplying the baseline’s counts by a cheaper model’s rates. Compare cost per successful outcome with overall and category-specific quality. Record latency percentiles in the same environment and include failed requests in reliability measurements. If a candidate improves average accuracy but misses a critical category, apply the guardrail you agreed upon before seeing the result.

Tune parameters and interpret the result

After identifying a promising model and prompt, test settings that address an observed problem. Sampling settings can change response variation, but lower randomness does not establish factual correctness. Output limits may reduce cost while increasing truncation. Provider support varies, so document the exact settings used in each run. Prepare one comparison that includes the baseline, candidate, sample definition, total cost, successful outcomes, latency, and failure categories. For an illustrative evaluation, a candidate spending 7for950acceptableresultshasalowercostpersuccessthanabaselinespending7 for 950 acceptable results has a lower cost per success than a baseline spending 10 for the same number. It still fails if those 50 failures violate your guardrails. Do not hide disqualifying errors behind an average saving. A result without a clear advantage is also actionable. Keep the baseline if the apparent difference is small relative to run-to-run variation, or collect more evidence if the workload is underrepresented. Account for implementation and ongoing maintenance effort before treating a small inference saving as a worthwhile project.

Roll out with a rollback condition

Release an approved candidate to a bounded portion of traffic. Keep the baseline available and record which configuration served each task. If you compare live groups, check that their traffic mix is comparable; a candidate serving only short requests appears cheaper even without an underlying improvement. Monitor the same quality, cost, and latency measures used in evaluation. Define who can stop the release and what triggers that action, such as a rise in invalid outputs or a critical-category error. Verify that your rollback restores the model, prompt, and settings together. Expand traffic only after the owner reviews the observed results. After release, compare a complete reporting window with the baseline and record the realized saving, traffic changes, and remaining uncertainty. Revisit the configuration when the task distribution, provider behavior, or pricing changes. This completes one optimization cycle and leaves a reproducible record for the next one.