Skip to content

More quality, less spend: a practical framework for your AI stack

· 16 min read

AI model decisions are typically made once and rarely revisited. Not because teams are satisfied, but because there has been no systematic way to measure whether a different choice would be better. This guide walks through the 14 levers that determine your stack’s cost and quality, shows real benchmark data for each one, and gives you a framework for measuring and improving all of them continuously.

This is the strategy view, for the person deciding where to spend and where to cut. If you are an engineer wiring the same measurement into an agent pipeline as tool calls, start with the agent-native companion, measure the quality and cost drivers in your AI pipelines.

Before the framework, one data point. A 25-point quality improvement on a real benchmark run, with no model change. The only variable was the content in the RAG store.

Not every lever applies to every stack. The table below maps your current situation to the right starting point.

If you are seeing thisStart here
Costs growing, unclear whyLevers 4, 3, 2
Outputs inconsistentLevers 5, 6, 7
Model choice feels like a guessLevers 1, 2
Fine-tune ROI unclearLever 9
Compliance posture unknownLever 13
Scores unreliable or vary run to runLever 14
Stack works but feels expensiveLevers 2, 8

The evidence

Four data points from real benchmark runs. Each one shows a lever that is easy to leave unmeasured.

These results come from specific, dated runs on defined tasks, using real models through a real pipeline. They show how each model performed on those tasks, not a general ranking of model quality, which depends entirely on your task and data. Run your own to see your numbers.

The framework

Before you can pull any of the 14 levers, you need a benchmark. A benchmark is a named prompt you run repeatedly against the same models on a schedule. It is the measurement instrument that makes every lever in this guide actionable.

Without a benchmark, you are comparing snapshots taken at different times under different conditions. With one, you are comparing the same task, the same models, and the same scoring criteria, run after run. Every lever in this guide produces a number. The benchmark is how you get that number.

#LeverWhat it controls
1Quality toleranceDefine your bar before you measure against it
2Model selectionCheapest model that clears the bar
3Prompt optimisationTighter prompts reduce cost and qualify cheaper models
4System prompt auditPermanent per-call cost, written once and rarely revisited
5Pipeline quality (RAG)Better retrieval unlocks cheaper models
6Store contentThe variable that sets the ceiling on retrieval quality
7Diagnostic improvement loopWhich pipeline layer caused the failure
8ArchitectureOne model for every task is almost always wrong
9Fine-tune ROIIs your custom model paying off
10Drift monitoringCatch provider-side regressions before your users do
11Re-optimisationFind better options as the landscape changes
12Threshold alertingGet notified when a dimension breaches, no dashboard watching
13ComplianceModel updates break compliance posture before you know it
14Inference parametersLock temperature and seed for reproducible, auditable scores

Lever 1: Quality tolerance calibration

Before you can find the cheapest model that clears your quality bar, you need to define what your quality bar actually is. A quality threshold set at 80 qualifies different models than one set at 95. Without a defined threshold, it is easy to drift into over-specifying (paying for quality the task does not need) or under-specifying (shipping outputs below the real standard). Setting the number first is what keeps the rest of the decisions honest.

Quality tolerance is not a feeling. It is a number. Setting it precisely is the first step in building a stack that is neither over-engineered nor under-specified.

Lever 2: Model selection

The cheapest model that clears your quality threshold is the right model for that task. Finding it requires running the comparison on your actual prompts, not a leaderboard someone else published on their data. (The starting rates are the AI API pricing tables by provider.)

For this task, Qwen 3.8 27B clears a quality threshold of 95 at $2.38/month and 1136ms. Claude Opus 5 also clears it at $27.35/month and 5660ms. Both pass. The cost difference is 12x. The right choice depends on whether that quality gap matters for your use case. An agent can make exactly this call on your behalf: see how an agent picks the cheapest model that clears the bar.

Quality score · support ticket task

Lever 3: Prompt optimisation

A vague prompt produces inconsistent results across models. A constrained prompt, one that specifies format, structure, and scope, produces more consistent outputs and often qualifies a cheaper model that could not clear the bar before.

Vague prompt
Baseline

A loosely specified prompt. Models interpret the task freely.

vague prompt -- no system prompt
"Summarise this support ticket."
Claude Opus 5
90.9
Qwen 3.8 27B
83.7
GPT-4.1 Nano
83.3
GPT-4o Mini
74.7
quality score cost: $0.00009 to $0.01034/call
Specific prompt
Constrained instruction

The same task, precisely specified. Qwen gains 4.5 points. The prompt changed the eligible model set.

specific prompt -- no system prompt
"Summarise in 3 bullets: what they want, the cause, the next step."
Claude Opus 5
91.7
Qwen 3.8 27B
88.2
GPT-4.1 Nano
79.9
GPT-4o Mini
65.9
Qwen up 4.5pts cost: $0.00007 to $0.00902/call

With a vague prompt, Qwen scored 83.7. With a specific prompt covering the same task, it scored 88.2, a 4.5-point lift at essentially the same cost. The prompt changed which models cleared the quality threshold. GPT-4.1 Nano dropped 3.4 points with the specific prompt, which is also useful data: not every model responds the same way to constraints. For a full run with per-criterion diagnostic data showing exactly where each model gained and lost, see the prompt is the ceiling.

Lever 4: System prompt audit

A system prompt is added to every call. A well-specified one can lift quality and reduce cost by constraining output format and length. Because it is written once and then runs on every call, it rarely gets revisited, so the questions worth asking go unanswered: is it still necessary, could it be shorter, is it helping or hurting quality? A benchmark answers all three.

With a specific prompt and no system prompt, Claude scored 91.7 and Qwen scored 88.2. Adding a structured system prompt lifted both to 92.5 and reduced cost per call. The system prompt produced shorter, more constrained outputs. The difference between lever 3 and lever 4 is the variable: lever 3 tests the prompt text, lever 4 tests the system prompt layer on top of it. For a full 2x2 run showing how the two variables interact across five models, and why Claude behaves differently from every other model when they conflict, see the system prompt is not neutral.

Lever 5: Pipeline quality (RAG and context)

On a complex RAG pipeline, the quality of what you feed the model determines which models are even eligible. A better pipeline unlocks cheaper models that could not clear the bar before.

GPT-4o Mini passes on a simple prompt. On a RAG pipeline with a quality threshold of 95, it passes half the time. The pipeline complexity is the variable, not the model.

Lever 6: Store content, the ceiling on retrieval quality

If your RAG store content is ambiguous, incomplete, or poorly structured, no model can compensate for it. Testing two versions of your store against the same model and prompt tells you whether improving your content improves your outputs, and by how much. In a real two-store A/B, the same model scored 50 on a thin returns policy and 92 on a complete one: see how the store content sets the quality ceiling.

For teams running RAG on a knowledge base, the quality of the underlying documents is the ceiling on what any model can achieve. A benchmark with two store versions makes that ceiling visible and measurable for the first time.

Content teams can now answer a question they have never been able to answer before: did the work we did on our documents actually make the AI better?

Lever 7: Diagnostic improvement loop

When a score is lower than expected, the question is which of the seven pipeline layers caused it. The diagnostic reads all seven: prompt, system prompt, context, parameters, criterion, model, and scoring. It returns a specific finding with a specific fix.

Diagnostic finding (Context stage)

Observation: Retrieved context chunk truncated at compliant example for Clause 1.3.

Evidence: “Compliant: Score blends heuristic and LLM judg…”

Fix: Provide the full untruncated example text from APPENDIX B in your compliance store.

Outcome
Quality lift from 75 to 100 on the affected criterion. The fix was in the store. The model never changed.

The diagnostic did not say the model was wrong. It said what to change and where. It is an easy finding to miss, because the instinct is to tune prompts and parameters while the real problem sits in the source documents. For a full before/after on a real benchmark run where 19 of 20 diagnostic findings pointed to the rubric rather than the model, see how the diagnostic improvement loop works in practice. For the model selection data (the same seven models on a harder task where the scores actually diverge), see model selection at the right complexity level.

Insight: Compliance rubric scoring and compliance stores are Pro Plus features. If your outputs need to align with internal policies or regulatory documents, Pro Plus adds compliance scoring, compliance stores, and full pipeline diagnostics.

Run your first benchmark

Schedule your prompts against every major model. Quality, cost, and latency tracked over time.

Run your first benchmark

Lever 8: Architecture and task-model matching

Applying one model uniformly across every task is the common default, and it leaves savings on the table. Every task produces different output complexity. A simple classification task does not need the same model as a customer-facing response that will be read by a regulator.

A team running four LLM tasks (summarisation, classification, generation, and extraction) with a single frontier model is almost certainly over-spending on at least three of them. Each task is a separate benchmark with its own threshold. The table shows four separate benchmarks, each with a threshold matched to that task’s quality requirement. Run each task type independently. The benchmark shows you which model clears your threshold at the lowest cost.

TaskQuality scoreCost per callPasses threshold
Classification95$0.00007 (GPT-4.1 Nano)Yes
Summarisation88$0.00079 (Qwen 3.8 27B)Yes
Customer-facing generation92$0.00400 (Kimi K3)Yes
Compliance-critical output91$0.00902 (Claude Opus 5)Yes

Cost figures are real per-call costs from benchmark runs. Each task is a separate benchmark with its own threshold.

Lever 9: Fine-tune ROI

A fine-tuned model trained on your domain data can outperform frontier models on your specific tasks. Running the comparison on your own context, with your own quality threshold, tells you whether the training investment is paying off before you commit to the next run.

ModelQualityCost per call
our-ft-model-v188.2$0.012
Kimi K388.2$0.004
DeepSeek V4 Flash85.1$0.00052

Register your endpoint and run this benchmark on your own fine-tune.

The benchmark does not tell you fine-tuning is wrong. It tells you whether this fine-tune, on this task, at this cost, is the right choice. In a real run, a registered endpoint beat both frontier models on quality while costing more per call: see benchmark your own model against the frontier for the full quality-versus-cost tradeoff, or the Benchmark Your Own Model overview for everything you can register and measure.

The same workflow applies to any pipeline you own. A RAG pipeline, an agentic workflow, or a multi-step backend can be registered as a BYOE endpoint and benchmarked against frontier models in the same run. If your pipeline (which includes retrieval, reranking, and a custom system prompt) outperforms a raw frontier model on your task, you have evidence the architecture is adding value. If a hosted model matches your pipeline’s quality at a lower cost per call, the benchmark tells you that too. You own the workflow. LLM Prover owns the measurement.

Lever 10: Drift monitoring

Model providers update their models without announcing it. The model you benchmarked last quarter may behave differently today. Scheduled benchmarks catch that change before it reaches your users.

Teams that pin to a specific model version avoid unexpected drift but miss improvements. Teams that do not pin get improvements automatically but may get regressions too. Drift monitoring gives you the signal either way.

If your stack runs programmatically, the same benchmark can be triggered via the API or called by an agent via MCP. The monitoring loop runs without a human initiating it, and the agent even remembers what it was watching across sessions, so a fresh session picks the series up where the last one left off.

One run
What a single run shows

One run on the RAG pipeline benchmark (threshold 95) shows all three models passing. No reason to question any of them.

single run -- quality score
Kimi K3
100
DeepSeek V4 Flash
100
GPT-4o Mini
100
run 1 of 1 -- all models pass today
12 runs
What repeated runs reveal

Twelve runs on the same benchmark. GPT-4o Mini passes half the time. The single run gave no indication of this.

pass rate -- 12 runs -- threshold 95
Kimi K3
12/12
DeepSeek V4 Flash
10/12
GPT-4o Mini
6/12
GPT-4o Mini: unreliable on this pipeline

Drift monitoring is reactive. It catches a regression you did not cause and did not expect. You find out first, not from your users.

Quality score · 12 scheduled runs (threshold: 95)

Lever 11: Re-optimisation

Drift monitoring catches regressions. Re-optimisation finds opportunities. A new model enters the market. A provider drops their pricing. A model that could not clear your quality bar six months ago now can. A scheduled benchmark tells you when the landscape has shifted in your favour.

Lever 12: Threshold alerting

Once you know your quality, cost, and latency thresholds, you can set alerts that fire the moment any dimension breaches them. You stop monitoring dashboards and start getting notified when something actually needs attention.

For teams running automated pipelines, a threshold breach can trigger a downstream action via the API: a Slack alert, a CI gate failure, a model substitution script. The alert is the event. What happens next is yours to define.

Lever 13: Compliance, where model updates break your posture

If your AI outputs need to align with internal policies, regulatory documents, or operational standards, a model update can break that alignment without warning. Scheduled compliance benchmarks catch the change before it reaches a user, an auditor, or a safety-critical system.

In the real benchmark run shown in the evidence section, the Availability criterion scored 0. The diagnostic pointed to the criterion definition. It applied a tier-stating requirement the prompt did not supply. That is a Criterion stage finding: the rubric itself needed tightening, not the model.

Compliance scoring returns a pass or fail per clause, each carrying the exact regulation text the judge applied, so a result is auditable rather than a single number. For a full run scoring AI marketing copy against a regulatory document clause by clause, see compliance scoring that cites the clause.

Lever 14: Inference parameters

At temperature 0.7 with no seed, the same prompt can produce very different outputs on every run. For a quality benchmark that is noise and for a compliance benchmark, which needs to be reliable and deterministic, it is worse: the score changes every time you run it. You cannot show a sample to an auditor.

Low temperature (0.0 to 0.2) plus a fixed seed produces near-identical outputs on repeated runs. The benchmark becomes a measurement, not a lottery. That is the setting that makes a compliance result auditable and defensible. Parameters are a lever you test rather than a knob you assume, though: see why measuring beats guessing on inference settings.

The improvement loop

The levers are not independent. Improving one often unlocks another, and the compound effect is where the real ROI lives.

A single diagnostic finding that improved three levers simultaneously:

Finding (Lever 7, Context stage)
Retrieved context chunk truncated at compliant example for Clause 1.3.
Fix (Lever 6, Store content)
Restructure the compliance store: provide the full untruncated example text from APPENDIX B.
Outcome (Lever 2 unlocked)
Quality 75 to 100 on the affected criterion. With better retrieval, a cheaper model now cleared the quality threshold.

One finding. Three levers improved. The diagnostic pointed to the store. Fixing the store changed which models cleared the threshold. The improvement loop ran once and produced a compounding result.

This is the loop: measure, diagnose, fix, re-measure. Each pass produces a better pipeline and a lower cost floor.

Where to start

Start with the lever most relevant to where your stack is today.

You do not know which model to use. Start with lever 1: set your quality threshold. Then lever 2: run the comparison. The cost and quality table will show you where to draw the line.

Your outputs are inconsistent and you do not know why. Start with lever 7: run a diagnostic. The finding will tell you which layer to fix. Most of the time it is not the model.

Your AI costs are growing and you cannot explain why. Start with lever 4: audit your system prompts. Then lever 3: tighten your prompts. Then lever 2: check whether a cheaper model now qualifies.

You now have a framework for measuring and improving every layer of your AI stack. Fourteen levers. A benchmark as the measurement instrument. A diagnostic that reads all seven pipeline layers and returns specific, actionable findings. And an improvement loop that compounds. Each fix unlocks the next. The stack is never done, because the landscape keeps changing. The benchmark keeps it current.

benchmarking cost-optimisation rag compliance thought-leadership