Key takeaways
- Cost per successful task, total spend including retries and escalations divided by successful tasks, is a better AI cost metric than price per token.
- Five common ways to reduce AI costs are model routing, context trimming, prompt caching, batching, and output limits.
- Each lever can backfire: a smaller model can trigger retries, and trimmed context can produce longer, pricier answers.
- Test every cost change like a risky release, with a baseline, offline evals, an online experiment, and a guarded rollout.
To reduce AI costs while keeping quality in check, optimize cost per successful task rather than price per token. Route routine requests to smaller models, trim context, cache repeated prefixes, batch work that can wait, and cap output. Then test each change against cost, quality, and latency on real traffic before you roll it out to everyone.
For AI applications and agents your team builds and runs, the model bill grows with usage. In a June 2025 report on its own research system, Anthropic found that its agents use about four times more tokens than chat interactions. Its multi-agent systems use about 15 times as many.
The standard fixes are well known: route easy requests to smaller models, trim the context, cache what repeats, batch what can wait, and cap the output. Each of these can work, but they can also backfire. A smaller model can fail on hard inputs and trigger retries. A shorter context can produce a longer answer. In an agent workflow, a cheaper step can make a later one more expensive.
For each cost-saving tactic, identify which part of the task’s cost it reduces, what it could make more expensive, and how to verify the saving before rollout.
What you actually pay for in an AI feature
Price per token is the easiest number to find, but on its own it’s the wrong one to optimize for. The number that matters is what you spend to complete one task successfully:
Cost per successful task = Total spend on every task you attempted, including retries and escalations ÷ Number of successful tasks
The total cost of an AI feature depends on six factors:
- Price per token, set by the model you call and by discounts such as caching and batching
- Input tokens, including the system prompt, retrieved context, conversation history, and tool definitions
- Output tokens, which are priced higher than input
- Steps per task, counting every model call, tool call, and handoff between agents
- Retries and escalations, when a call is repeated after a failure or a hard request is sent again to a stronger model
- Failed tasks that users redo or abandon, which still cost money and produce nothing
The difference between input and output pricing can make seemingly minor changes expensive. As of October 2026, Claude Opus 5.5 lists $4 per million input tokens and $20 per million output tokens. OpenAI lists GPT-5.5 at $5 and $30, respectively, for prompts up to 272K input tokens.
At Opus 5.5 rates, a call using 2,000 input tokens and 500 output tokens costs $0.008 for input and $0.010 for output, or $0.018 in total. Trimming 500 input tokens saves $0.002. If the trimmed context makes the answer 100 tokens longer, those tokens cost $0.002, and the savings disappears.
Success rates can change the result just as dramatically. Suppose variant A costs $0.09 per attempt and succeeds 95% of the time, and variant B costs $0.07 per attempt and succeeds 75% of the time. Per attempt, variant B looks 22% cheaper. Per successful task, variant A costs about $0.095 and B about $0.093, so the saving shrinks to about 1.5% before you count the users who give up or try again. (These figures are illustrative, not precise measurements.)
Decide what counts as success
Cost per successful task only works as a metric if you decide what counts as success before you measure. For an agent, success is an outcome you can count, such as a completion event your application already records, a passing judge score, a user who doesn’t retry or rephrase within a set window, or a conversation that never reaches a human.
Pick the signal closest to what the user came to do, and keep it fixed while you compare variations. Check a judge’s score against a sample of human-reviewed outcomes before you trust it, or pair it with a behavioral signal such as no retry. For an open-ended chat with no clear completion, a proxy such as rephrase rate or a judge score is the practical choice, as long as you name the one you picked.
Then calculate cost per task rather than per call. Give each task an ID, such as a conversation ID, that travels with every model call, tool call, and retry across your agents, so you can add up everything one task spent, including attempts that failed. The result is also a number you can report upward in your organization, because a cheaper change that hurts quality shows up as a higher cost per successful task, not as a savings.
Price per token doesn't compare across models
Price per token also doesn’t transfer cleanly across models. Claude 4.7 and later models use a tokenizer that produces approximately 30% more tokens for the same text than the previous tokenizer in Claude Sonnet 4.6 and earlier. The exact increase depends on content and workload. A model with the same or lower list price can cost more per task if it needs more tokens, steps, or retries to finish.
A higher list price doesn’t guarantee better answers either. In a 2025 experiment we ran at LaunchDarkly with two earlier-generation models, simulated users, and Claude-judged responses, Claude Opus 4 scored worse than GPT-4o on judged feedback and ran 81% slower at p95, at 99.5% and 91% confidence. It also cost about 33% more, though that difference didn’t reach our 90% confidence bar.
Since the experiment used simulated users and a model judge, view it as an example of workload-specific testing rather than a universal model comparison.
5 ways to reduce AI costs, and how each can backfire
These methods can reduce AI agent costs, but there’s no guarantee you’ll get lower costs across a complete task. Each lever moves one term of the cost-per-successful-task equation and can push another term up. That makes every cost change a production change, so test it the way you’d test any risky release.
The documented ceilings give a sense of scale. Batch requests on Anthropic and OpenAI cost half the standard price. A cache hit on current Claude models and OpenAI’s GPT-5 and later models costs a tenth of the input price or less.
Negotiated discounts and fine-tuned smaller models change the price term too, and they need the same per-task test. For model-by-model prices and deployment options, such as self-hosting, see our LLM pricing comparison.
Five ways to reduce AI costs, what each lowers, and how it can backfire
Lever | What it lowers | How it can backfire | What to watch |
|---|---|---|---|
Model routing | Price per token | Misses on hard inputs cause retries and escalations | Success rate and judge scores by request type |
Context trimming | Input tokens | Missing context leads to longer or wrong answers | Output tokens and cost per task |
Caching | Price of repeated input | Prefix changes cause cache misses and write premiums | Cache hit rate after each prompt change |
Batching | Price of work that can wait | Delay breaks interactive and agent-loop steps | Latency budget per path |
Output limits | Output tokens | Cut-off responses force retries or follow-ups | Incomplete-response rate and follow-up calls |
Route routine requests to smaller models
Model routing can reduce AI model costs by sending more routine requests to a cheaper model and saving a stronger model for more complex ones. In a RouteLLM study, learned routers chose between one strong and one weak model. In certain cases, they cut costs by more than half without lowering response quality on the benchmarks tested.
However, routing can backfire when the router misjudges a difficult request. When a weaker model misses a hard input, your system retries, the agent makes extra tool calls, or the user gets an answer they have to redo. Each of those adds cost to the same task. Escalation can handle the miss for a single request by sending it to a stronger model, which can fix the answer, but that still means you pay for both calls.
Maintain a stronger configuration as a broader fallback if quality declines across a specific class of requests. Monitor success rates and judge scores for your most difficult request types, not just overall averages.
Trim context and prompts
Trimming lowers input tokens per step. Tighter retrieval, summarized conversation history, and leaner system prompts all reduce what you send on every call.
The risk is what the model does without the context it lost. It may call a tool to look up what’s missing, ask a clarifying question that adds a turn, write a longer answer to cover the gap, or get the answer wrong. Because of the price gap between output and input, a small increase in an answer’s length can cancel a large cut in input.
Watch output tokens per request alongside input tokens. In one of our experiments described below, aggressive redaction upstream made a downstream agent write longer answers and raised total cost per request. In that test, total cost per request rose from $0.0246 to $0.0281.
Cache repeated prompt prefixes
Prompt caching bills a repeated prompt prefix at a fraction of the input price. On most current Anthropic and OpenAI models, a cache hit costs one-tenth or less of the standard input price.
The savings you reap depend on reuse. System prompts, tool definitions, and other stable content should appear before timestamps, user details, and frequently changing context. If the prefix changes between requests, the system may pay the standard input prices, or a cache write premium, without receiving the discount from later hits.
Watch the cache hit rate after every prompt change, and verify your provider’s minimum prompt length and expiration rules before including any projected cache savings in your cost estimate.
Batch work that can wait
Batch processing trades speed for price. Currently, Anthropic and OpenAI both charge 50% of standard prices for batch requests, with results returned within 24 hours. On Anthropic the batch discount stacks with caching.
Evaluation runs, backfills, and offline enrichment are good candidates since they don’t require immediate responses. A step inside an agent loop, where the next step requires the answer now to advance, is usually not a good candidate, and moving it to a batch queue breaks the task instead of making it cheaper.
Set a latency budget for each workflow, and batch only the paths whose budget can absorb a delay of up to 24 hours.
Limit output length and shape the response format
Output tokens are often the most expensive tokens you buy, so capping the response length is a strong optimization target. Max-token limits, shorter or structured response formats, and instructions that discourage padding all reduce output per call. On reasoning models, the reasoning-effort or thinking-budget setting is an output lever too, because reasoning tokens are billed as output.
A cap that’s too low trades a cheaper call for a broken one. When a Claude response hits the max_tokens limit in the middle of a tool call, you have to retry the request with a higher limit to get the complete tool use, so you pay for that call twice. On OpenAI reasoning models, hidden reasoning tokens are billed as output tokens, and a response that reaches max_output_tokens comes back incomplete. OpenAI warns that you “could incur costs for input and reasoning tokens without receiving a visible response.” And a response format that’s too terse carries a milder version of the same risk, because an answer the user can’t act on turns into a follow-up call.
Monitor the rate of cut-off or incomplete responses, the number of follow-up calls per task, and task completion.
How one cheaper step can raise the cost of the whole task
Routing, trimming, caching, batching, and output limits can each be modeled on a single call, but an agent isn’t a single call. Its steps are coupled, and trimming input at one step changes the output at the next. A weaker model at one step changes the retry rate for the whole task, and a prompt edit changes the cache hit rate on every call that shares the prefix.
Take the single call from earlier (2,000 input and 500 output tokens at Opus 5.5 rates) and extend it to a four-step task at $0.018 per step, or $0.072 per task. You trim 1,000 tokens of retrieved context from step one and save $0.004. Without that context, two later steps each write 150 more tokens to work around the gap. At $20 per million output tokens, that adds $0.006. The task now costs about 3% more than it did, and a dashboard that tracks step one still shows a saving. If those longer answers become input for the next step, the cost climbs further.
Because agents use far more tokens and steps than a chat interaction, a per-step regression repeats across every step that inherits it, and so does a savings.
Our AI experiments ROI guide found this pattern in practice. Replacing an upstream security agent with a free Mistral model that applied aggressive PII redaction moved the total cost per request from $0.0246 to $0.0281, an increase of about 14%.
In that experiment, redaction removed context, so the downstream support agent wrote longer answers, and total cost went up. Treat the result as directional: the experiment used simulated users, Claude-judged responses, and reached only 79% confidence against a 90% Bayesian bar.
How to test a cost change with fewer quality regressions
Treat a cost change the way you’d treat any risky release. You can assemble the steps below from separate tools for tracing, evaluation, and feature flags. The catch is the handoffs between them: evals live in one tool, behavior control in another, and acting on what you learned can still require a redeploy.
The examples below use LaunchDarkly AgentControl, a control plane for agents in production. AgentControl stores prompts and model settings as versioned variations outside your code, so you can serve, compare, and roll back a change without a deploy. Setup details are in our optimize AI cost cheatsheet.
Not every change needs all seven steps. Batching an offline job or caching a prompt you haven’t changed leaves what users see the same, so your provider bill can confirm the savings. A change to the model, prompt, context, or output limit changes what users receive, and that’s where the full workflow earns its time. Match the effort to the potential savings, as well as the cost of getting things wrong.
- Set a baseline for each variation. Before you change anything, record tokens, cost, latency, errors, and satisfaction for the current configuration. Without a baseline, you can’t tell a saving from noise. The AgentControl monitoring view reports these metrics per variation, with cost calculated from input and output token prices. Check that estimate against your provider bill, since discounts and tool fees can change the actual amount. To get cost per successful task, send your success signal as a custom event, attach it as a metric, and divide each variation’s cost by its successes.
- Define the candidate change as a variation, not a code edit. A new model, a trimmed prompt, or a lower output cap becomes a variation of an AgentControl config, which you can serve to a slice of traffic and compare with the baseline.
- Run an offline eval. Test candidates against a benchmark dataset scored by judges before any user sees them. Offline evaluations cut weak options early, so you can focus production traffic on the candidates that clear your quality bar.
- Run an online experiment on real traffic. Roll the surviving variations out to a percentage of traffic and measure four groups of metrics together:
Cost, as cost per successful task, backed by tokens per request and spend per 1,000 calls
Latency, as time to first token and total response time
Quality, as judge scores for correctness, relevance, and safety
Outcome, as task completion and user satisfaction - Design the experiment for the noisiest metric, which is usually cost, because tokens and steps per task vary widely from one request to the next. Our ROI guide estimates that cost and feedback may need 5,000 to 10,000 or more samples to reach confidence, compared with roughly 1,000 for latency. On a path that won’t reach that volume in a reasonable window, lean harder on offline evals, run the experiment longer, or start with a higher-volume step.
Online evaluations can score a sample of production responses rather than every one. Our tutorial on when to add online evals suggests sampling 10–20% of traffic to balance coverage against the cost and latency of judging. - Roll out with guardrails. Once the experiment has ended, expand the winning variation gradually, with thresholds for cost, latency, and quality. A guarded rollout monitors those metrics as exposure grows. If one regresses, it can pause the rollout and notify you, or roll the change back automatically if you’ve enabled that option.
End the experiment before starting the rollout, since the two can’t run on the same config at once. Many LaunchDarkly plans include a limited trial of guarded rollouts. Without them, increase a percentage rollout manually while watching the same thresholds. That’s slower and has no automatic rollback.
For a routing change, keep a stronger variation defined as the fallback, and serve it without a code change by updating the config’s default rule or targeting rules. - Promote the winner and make it the new baseline. Once the candidate meets your expectations at full exposure, its metrics become the baseline for the next change. Versioned configs and a variation history let you compare the next change against this one. Approvals for production config changes and a kill switch or fallback help protect the new baseline if spend or quality crosses a threshold.
Rerun the loop when models, prices, or traffic change
The goal is a repeatable process for finding the least expensive configuration that still meets your quality and latency needs. New models, prices, tokenizers, and shifts in what your users ask all alter the equation. And a variation that won last quarter may no longer meet your requirements.
Start by picking your highest-volume agent step, set its cost-per-successful-task baseline, and test one lever against it.
Routing, caching, and batching are provider and architecture choices, and LaunchDarkly doesn’t make tokens cheaper. AgentControl works with the providers you already use, including OpenAI, Anthropic, Gemini, and Amazon Bedrock. With experimentation and release controls, AgentControl gives you runtime control over the models and prompts your agents use, so you can test those choices on real traffic and decide how far they roll out. It measures cost, latency, and quality side-by-side, and lets you keep a fallback ready if a “saving” ends up costing more than expected. Then, the winning configuration becomes the baseline for the next cycle of optimization.
Book an AgentControl demo to see it in action.
FAQs
How many more tokens do AI agents use than chat?
As of October 2026, AI agents use about four times more tokens than chat interactions, and multi-agent systems use about 15 times as many, according to Anthropic's June 2025 report on its own research system. Because each agent step can make several model and tool calls, a small per-call saving or regression repeats across the whole task.
How do you track the cost of a single AI agent task?
Give each task an ID, such as a conversation ID, that travels with every model call, tool call, and retry across your agents, then add up everything that ID spent, including failed attempts. Dividing that total by the number of successful tasks gives cost per successful task, which also exposes cheaper changes that hurt quality.
Why does the same prompt cost more on a newer model?
A newer model can use a tokenizer that splits the same text into more tokens. Claude 4.7 and later models produce approximately 30% more tokens for the same text than Claude Sonnet 4.6 and earlier, though the increase depends on content. Compare models on cost per task rather than list price per token.
How many samples does an AI cost experiment need?
Cost and user-feedback metrics may need 5,000 to 10,000 or more samples to reach confidence, compared with roughly 1,000 for latency, because tokens and steps per task vary widely between requests. On a lower-traffic path, lean harder on offline evaluations, run the experiment longer, or start with a higher-volume step.
When should you use batch processing for LLM requests?
Use batch processing for work that can wait up to 24 hours, such as evaluation runs, backfills, and offline enrichment. As of November 2026, Anthropic and OpenAI both charge 50% of standard prices for batch requests. Avoid batching a step inside an agent loop, where the next step needs the answer immediately to keep the task moving.





