Skip to main content
reopt Handbook
reopt Handbook
LLMOps and AgentOps in Production

Architecture and Release

Ch1. System ArchitectureCh2. Versioning and ReleaseCh3. Evaluation Framework

Operational Reliability

Ch4. Online GuardrailsCh5. Observability and SLOsCh6. Cost and Latency Optimization

Growth and Response

Ch7. Experiment OperationsCh8. Incident Management Runbook

Verification

Verification ReportVerification ArchiveUpdates
Handbook›LLMOps and AgentOps›Ch6. Cost and Latency Optimization
한국어English

Ch6. Cost and Latency Optimization

Manage model spend, response time, caching, routing, fallback, and quality checks together so AI services stay reliable within unit-cost targets.

Key takeaways

  • Manage model spend, response time, caching, routing, fallback, and quality checks together so AI services stay reliable within unit-cost targets.
  • Use this chapter as a first-pass operating checklist before changing systems, data, permissions, or customer-facing workflows.
  • Validate platform-specific details against current official docs or internal policy before rollout.

For AI services, cost and latency are two sides of the same operating problem.
Increasing model capability can raise cost; reducing cost can destabilize quality.

Budget Model

Monthly AI Cost=Requests×Unit Cost\text{Monthly AI Cost} = \text{Requests} \times \text{Unit Cost}Monthly AI Cost=Requests×Unit Cost Latency Budget=Tretrieve+Tinfer+Ttool+Tpost\text{Latency Budget} = T_{retrieve} + T_{infer} + T_{tool} + T_{post}Latency Budget=Tretrieve​+Tinfer​+Ttool​+Tpost​

Optimization Priority

PriorityLeverExpected Effect
1Improve cache hit rateImprove cost and latency together
2Optimize prompt lengthReduce token cost
3Model routingMatch cost to task complexity
4Async tool callsImprove p95 latency

Pareto Operating View

Optimize for the balance of cost and latency, not a single metric.

Utility=α⋅Quality−β⋅Cost−γ⋅Latency\text{Utility} = \alpha \cdot \text{Quality} - \beta \cdot \text{Cost} - \gamma \cdot \text{Latency}Utility=α⋅Quality−β⋅Cost−γ⋅Latency
  • Growth stage: raise α and prioritize quality.
  • Profitability stage: raise β and tighten cost controls.
  • Strict SLA stage: raise γ and prioritize latency.

Policy Example

routing_policy:
  - if: complexity <= 2
    model: 'cost_optimized'
  - if: complexity >= 4
    model: 'quality_optimized'

timeout_policy:
  tool_timeout_ms: 2500
  global_timeout_ms: 7000

2026 Model Pricing Baseline

The table below uses official pricing pages checked on 2026-05-17. Model prices change often, so store the baseline date with every release gate and budget calculation.

ModelInput (/1M)Cached Input (/1M)Output (/1M)Notes
GPT-5.5$5.00$0.50$30.00OpenAI flagship
GPT-5.4$2.50$0.25$15.00Coding and professional work
GPT-5.4 mini$0.75$0.075$4.50Lightweight coding/computer-use/subagent
Claude Opus 4.7/4.6/4.5$5.00$0.50$25.00Consider tokenizer effects for Opus 4.7
Claude Sonnet 4.6/4.5$3.00$0.30$15.00Sonnet 4 is deprecated
Claude Haiku 4.5$1.00$0.10$5.00Fast lightweight model

Current Anthropic lineup (checked 2026-09-05)

The table above is a 2026-05-17 snapshot and the Anthropic lineup has moved since. Use the values below for new routing policies and treat the snapshot as the budget basis of its own date.

ModelInput (/1M)Cache read (/1M)Output (/1M)Notes
Claude Fable 5.1$10.00$0.25$50.00Released 2026-09-01. Cache reads cost 2.5% of input (versus 10% elsewhere), which favors long agentic sessions
Claude Opus 5$5.00$0.50$25.00Default choice for most workloads
Claude Sonnet 5$2.00$0.20$10.001M context by default and cheaper than Sonnet 4.6 (3/3/3/15)
Claude Haiku 4.5$1.00$0.10$5.00200K context, fast and cheap

All four take the 50% Batch API discount, and Fable 5.1, Opus 5, and Sonnet 5 default to a 1M context window. Fable 5.1 is a covered model with 30-day data retention, so ZDR organizations need explicit authorization from Anthropic before using it. | DeepSeek V4 Flash | 0.14cachemiss∣0.14 cache miss | 0.14cachemiss∣0.0028 | 0.28∣1Mcontext,thinking/non−thinking∣∣DeepSeekV4Pro∣0.28 | 1M context, thinking/non-thinking | | DeepSeek V4 Pro | 0.28∣1Mcontext,thinking/non−thinking∣∣DeepSeekV4Pro∣0.435 cache miss | 0.003625∣0.003625 | 0.003625∣0.87 | 75% discount requires recheck by 2026-05-31 15:59 UTC |

Cost Strategy

The more important shift is not just lower prices. Cached input, batch processing, data residency, priority/flex handling, and tool runtime costs are increasingly billed separately. Model routing alone is not enough; manage cache hit rate and tool-call volume together.

2026 Cost Optimization Levers

Prompt Caching

ProviderMethodCached Read CostEffect
OpenAIAutomatic 1,024+ token prefix caching, prompt_cache_key, 24h retention on some modelsUp to 90% lower than standard inputCan improve latency by up to 80%
AnthropicAutomatic/explicit cache breakpoints, 5-minute/1-hour write, cache hit/refresh10% of base inputTool/system/message hierarchy changes can invalidate cache
DeepSeekContext cachingModel-specific cache-hit priceV4 Flash cache hit is $0.0028/M

Batch API

Anthropic and OpenAI both provide 50% batch discounts. Use batch for evaluation, classification, embeddings, and large replays that do not need immediate responses.

Tool/Runtime Costs

Cost ItemManagement Standard
Web searchTrack call count and result tokens separately
Code/container executionTrack container session time, file preload, stdout/stderr size
MCP/tool schemaTrack tool definition tokens and schema cache hit rate
Voice/realtimeSeparate audio tokens, first-audio latency, and interruption retry cost

Cost Ledger Example

cost_ledger:
  run_id: run_20260517_001
  model:
    input_tokens: 3840
    cached_input_tokens: 2560
    output_tokens: 620
    unit_cost_usd: 0.00418
  tools:
    web_search_calls: 1
    container_minutes: 3
    mcp_schema_tokens: 1800
  business:
    tenant_id: acme-enterprise
    task_success: true
    cost_per_successful_task_usd: 0.014

Model Routing Services

ServiceMethod
MartianReal-time model routing per prompt
Not DiamondPrompt transformation plus model selection
Unify AIQuality/cost/speed optimized routing
OpenRouterMulti-provider marketplace with caching support

Executive KPIs

  • Gross Margin with AI Cost
  • p95 Latency by Top Revenue Flows
  • Cost per Successful Task

Practice Tip

Cost reduction often comes first from reducing unnecessary output tokens, repeated tool calls, and cache misses, not from switching models. Recheck pricing before release and make operating decisions using cost per successful task.

Baseline and Sources

ItemBaseline DateRecheck ByPrimary Source
OpenAI model/tool pricing2026-05-172026-06-16https://openai.com/api/pricing/
Claude model/tool pricing2026-05-172026-06-16https://platform.claude.com/docs/en/about-claude/pricing
DeepSeek V4 pricing2026-05-172026-05-31https://api-docs.deepseek.com/quick_start/pricing/

Related docs

Updates

Changelog for LLMOps and AgentOps in Production

Verification Report

Structure, link, metric, and logic verification for LLMOps and AgentOps in Production

Cost and Reliability

Vercel Enterprise AI Platform · Manage AI cost, latency, error budgets, rate limits, fallback, and workload classes.

Pricing and Packaging

AI-Era GTM · Design AI-era SaaS pricing models, packaging, margins, and governance.

Earlier verification records

Claude Code Command Master · Claude Code: Earlier review dates, version baselines, and findings, with a link to the current verification scope.

Ch5. Observability and SLOs

Collect model, tool, and policy execution as traceable signals and operate them through SLOs

Ch7. Experiment Operations

Repeat prompt, model, and workflow experiments quickly and safely

On this page

Budget ModelOptimization PriorityPareto Operating ViewPolicy Example2026 Model Pricing BaselineCurrent Anthropic lineup (checked 2026-09-05)2026 Cost Optimization LeversPrompt CachingBatch APITool/Runtime CostsCost Ledger ExampleModel Routing ServicesExecutive KPIsBaseline and Sources