Pricing tells you what a provider charges per unit, such as $2 per million input tokens. Cost is what you pay for your workload. Total cost of ownership (TCO) also includes the infrastructure and staff needed to run the service. List the costs you include so you can compare two options fairly.
Rate-card review: November 10, 2026. Unless another unit is shown, table prices are USD per million tokens (MTok), using direct-provider Standard list rates. They exclude taxes, negotiated discounts, marketplace terms and regional/service modifiers unless stated. Current prices and announced future prices are separate. Workload sizes, staffing and comparison costs are interview assumptions.
| Remember the unit | Example | Common mistake |
|---|---|---|
| Rate × quantity | USD 2/MTok × 0.002 MTok = USD 0.004 | Treating 2,000 tokens as two million |
| Call vs task | Five model calls can serve one customer task | Multiplying customer tasks by one call’s bill |
| Usage vs outcome | Failed attempts can still consume billed resources | Dividing only successful-attempt spend by successes |
| Estimate vs invoice | Apply rates to recorded usage, then compare with the invoice | Treating an incomplete stream as zero cost |
| Total vs marginal cost | Idle reserved GPUs still cost money | Adding paid idle capacity a second time |
Read tokenization, capability assessment and model selection alongside the calculations.
Token units and rates
A token is a unit produced by a model's tokenizer, not a fixed number of words. Two models can tokenize the same text differently. A price quoted per million tokens must be multiplied by the measured token count divided by one million. Input and output can have different rates, and the provider's usage fields determine which categories are billable.
Use these example rates to estimate a call:
- Input: At $2 per million tokens, 2,000 tokens cost 2,000 / 1,000,000 × $2 = $0.004.
- Output: At $10 per million tokens, 500 tokens cost $0.005.
- Total: One call costs $0.009 before tools, storage, or other charges. At this rate, 100,000 calls cost $900. If each user task takes five calls, those calls serve 20,000 tasks.
Partition cached usage without double-counting
Suppose a provider reports 10,000 total input tokens, of which 8,000 are eligible cache reads. In an illustrative contract, uncached input costs $2 per million, cache reads cost $0.20, and 1,000 output tokens cost $10 per million. The input is 2,000 uncached tokens plus 8,000 cached tokens, not 10,000 uncached plus another 8,000 cached. The bill is $0.004 + $0.0016 + $0.01 = $0.0156 before any separate cache creation or storage charge.
Use the provider’s billing documentation to match each usage field to its charge. For example, a provider may charge a separate rate to write tokens to the cache, or it may include reasoning tokens in the output total. Record the billing rules next to the estimate so each token is counted once.
Provider prompt caching reuses eligible prompt processing. An answer cache returns a previous answer. The latter requires an additional correctness decision: do the query, user permissions, source versions, and freshness make reuse appropriate? Similar wording alone is not enough.
From a rate card to a workload forecast
Group requests by workload, such as short support answers and long document reviews. Estimate the volume and average cost of each group, then add the totals. Include tool calls, retries, escalations, higher rates for long prompts, media charges, and any service options you use. Record current rates, announced changes, and unconfirmed rates separately. If a discount expires, estimate spending at the rate that takes effect afterward.
Add the costs of preparing documents, generating embeddings, running search indexes, storing and transferring data, monitoring the service, and paying for human review. Include staff time and spare capacity where they apply to the option you are pricing.
For a worked estimate, state the rate and its unit, show how many units the task uses, and add fees such as tools and storage. The tables below show example billing units and dated provider rates.
Table of Contents
- What Appears on the Bill
- Current Text API Pricing
- Specialist APIs and Tool Fees
- Cost Calculation
- Worked Examples
- Context Caching Economics
- Cost Optimization
- Self-Hosting Economics
- Total Cost of Ownership and FinOps
- API versus self-hosted worksheet
- Forecast boundary cases
- Full FinOps design interview
- Interview questions
- Official Sources
What Appears on the Bill
A production request can create several independently billed quantities:
| Cost category | What to measure |
|---|---|
| Uncached input | System instructions, user input, retrieved context, images converted to tokens, tool schemas, and prior conversation state |
| Cached input | Reused prompt-prefix tokens actually reported as cache hits |
| Cache writes and storage | Tokens written into a cache, the cache duration, and any token-hour storage fee |
| Output and reasoning | Visible output plus any provider-billed reasoning or thinking tokens |
| Tools | Search queries, retrieval calls, code containers, computer use, and other server-side tools |
| Media | Audio minutes or tokens, generated images, video seconds, OCR pages, and transcription |
| Service and region | Batch, flex, fast/priority, data-residency, or marketplace modifiers |
| Failure overhead | Retries, fallbacks, agent loops, shadow traffic, evaluation traffic, and partial failures |
The general monthly model is:
where token quantities are measured in millions and the non-token fees are monthly totals counted once. Media converted to billed model tokens belongs in the token term; use separate media fees only for distinct charges. Add serving infrastructure, observability, human review, support, and incident costs when comparing total cost of ownership.
There is no universal enterprise discount schedule. Volume discounts, committed capacity, support, regional routing, and cloud-marketplace terms are provider- and contract-specific. Use a written quote for a procurement model.
Current Text API Pricing
OpenAI text models
| Model | Input | Cached input | 30-minute write | 12-hour write | Output |
|---|---|---|---|---|---|
gpt-6-astra |
$10.00 | $1.00 | $12.50 | $25.00 | $50.00 |
gpt-6.1-sol |
$2.00 | $0.10 | $2.50 | $5.00 | $10.00 |
gpt-6.1-terra |
$1.00 | $0.05 | $1.25 | $2.50 | $5.00 |
gpt-6-luna |
$0.10 | $0.01 | $0.125 | $0.25 | $0.50 |
gpt-5.6-sol — older model |
$4.00 | $0.40 | $5.00 | $10.00 | $20.00 |
For these models, prompts above 272K input tokens use whole-request long-context rates. Input and both cache rates double, and output costs 1.5× as much. For example, GPT-6.1 Sol charges $4 for fresh input, $0.20 for cache reads and $15 for output, per million tokens. The bill applies those rates to the whole request, including the first 272K input tokens.
Where supported, Batch and Flex cost half the Standard rate and Fast costs twice Standard. The published Ultrafast rates for Astra and GPT-6.1 Sol are six times Standard. Eligibility differs by model and region. For example, GPT-6.1 Sol supports Ultrafast with EU data residency, while Astra's Ultrafast tier supports global processing and US data residency. Eligible regional processing adds 10%. The rate card now lists November 30, 2026 as the end of GPT-5.6 Sol's promotional pricing. Check the rate in effect before pricing a later workload. OpenAI rate card · GPT-6 guide
Astra and GPT-6.1 Sol both require a reasoning setting other than none. Billable output can include reasoning tokens beyond the answer the user sees. Astra's short-context input and output rates are five times GPT-6.1 Sol's. Compare token usage and retries on the same task before assuming the bill also grows fivefold.
Anthropic Claude
| Model | Base input | Cache read | 5-minute write | 1-hour write | Output |
|---|---|---|---|---|---|
| Claude Fable 5.2 | $8.00 | $0.20 | $10.00 | $16.00 | $40.00 |
| Claude Opus 5.5 | $4.00 | $0.20 | $5.00 | $8.00 | $20.00 |
| Claude Sonnet 5.5 | $2.00 | $0.10 | $2.50 | $4.00 | $10.00 |
| Claude Haiku 5.5, up to 100K input tokens | $0.10 | $0.01 | $0.125 | $0.20 | $0.50 |
| Claude Haiku 5.5, over 100K input tokens | $0.50 | $0.05 | $0.625 | $1.00 | $2.50 |
Cache reads cost 2.5% of the base input rate for Fable 5.2, 5% for Opus 5.5 and Sonnet 5.5, and 10% for Haiku 5.5. Restricted-access Mythos 5.2 shares Fable's rates. Haiku's higher tier applies to the request when input exceeds 100K tokens, including its output and cache rates. Claude pricing
Batch halves input and output rates. The other Claude models in the table use the same token rates across their full context windows. On the first-party Messages API, Fable 5.2 Fast costs $16 input and $80 output per million tokens. Opus 5.5 Fast costs $8 and $40. Check which platforms support Fast and which options can be combined. US-only inference_geo on eligible deployments adds 10% to token categories. Recount tokens on representative inputs when switching versions, since tokenizers can split the same text differently. Claude pricing
Google Gemini
| Model | Standard input | Cached input | Cache storage | Standard output |
|---|---|---|---|---|
gemini-4-argon through Nov. 30, 2026 |
$2.00 | $0.10 | Implicit caching only | $10.00 |
gemini-4-argon starting Dec. 1, 2026 |
$4.00 | $0.20 | Implicit caching only | $20.00 |
gemini-3.8-flash / gemini-3.7-flash through Dec. 31, 2026 |
$0.75 | $0.075 | $0.50 / MTok-hour | $3.75 |
gemini-3.8-flash / gemini-3.7-flash starting Jan. 1, 2027 |
$1.50 | $0.15 | $1.00 / MTok-hour | $7.50 |
gemini-3.5-flash |
$1.50 | $0.15 | $1.00 / MTok-hour | $9.00 |
gemini-3.5-flash-lite |
$0.30 | $0.03 | $1.00 / MTok-hour | $2.50 |
Google's output price includes thinking tokens. Check separate cache and storage rates for each processing tier. Argon is paid-tier only and supports implicit caching. An application that passes an explicit cache resource on a Flash request needs a separate integration path for Argon. Gemini 3.8 Flash and 3.7 Flash have the same Standard rates in this snapshot. Paid-tier content has different data-use terms from free-tier content. Gemini Developer API pricing
gemini-3.1-pro-preview has a two-tier standard rate: $2 input / $12 output for
prompts up to 200K tokens, and $4 / $18 above 200K. It is a preview model, so
its lifecycle risk belongs in the decision alongside price.
xAI, Mistral, and DeepSeek
| Provider | Model | Input or cache miss | Cached input | Output |
|---|---|---|---|---|
| xAI | grok-4.7 |
$2.00 | $0.50 | $6.00 |
| Mistral | Mistral Large 4 | $0.70 | $0.07 | $2.10 |
| Mistral | Mistral Small 4 | $0.15 | $0.015 | $0.60 |
| Mistral | Ministral 3 14B | $0.20 | $0.02 | $0.20 |
| Mistral | Ministral 3 8B | $0.15 | $0.015 | $0.15 |
| Mistral | Ministral 3 3B | $0.10 | $0.01 | $0.10 |
Grok 4.7 has a 500K context window. At 200K prompt tokens or more, its whole-request rates become $4 input / $1 cached input / $12 output. xAI's current rate card now publishes both tiers explicitly. The US regional endpoint adds 10% to token rates.
DeepSeek has separate peak and off-peak rates:
| API model / current version | Peak input miss | Peak cache hit | Peak output |
|---|---|---|---|
deepseek-flash / V4.1 Flash 1017 |
$0.30 | $0.006 | $1.20 |
deepseek-v4-pro / V4 Pro 0813 |
$1.32 | $0.044 | $3.96 |
Off-peak is half of every listed rate. Peak windows are Monday–Friday 01:00–04:00 and 06:00–10:00 UTC, excluding Chinese public holidays. The October 17 Flash upgrade kept the same request name and rates. The old Flash names also route to 1017. Record the model version and billing window alongside each request's usage. DeepSeek rate card · DeepSeek changelog
Mistral figures above use its global Standard schedule; use the actual regional and service contract when budgeting. Mistral pricing.
Why the cheapest token row may lose
Rate tables do not normalize:
- provider tokenizers or media-to-token conversion;
- reasoning-token consumption;
- tool-schema and system-prompt overhead;
- successful-task rate, retries, or human correction;
- latency, capacity, and service tier;
- safety, governance, support, or data placement.
The decision metric should usually be cost per successful task at the required quality and service level, not cost per token.
Specialist APIs and Tool Fees
Do not compare unlike units as if they were all token prices.
| Provider / endpoint | Billing unit | Current standard list price |
|---|---|---|
OpenAI gpt-live-1 |
Session minute, billed per second | $0.05; backend models/tools extra |
OpenAI gpt-realtime-2.1 audio |
MTok input / cached / output | $32 / $0.40 / $64 |
OpenAI gpt-realtime-2.1-mini audio |
MTok input / cached / output | $10 / $0.30 / $20 |
OpenAI gpt-transcribe |
Estimated audio minute | $0.0045 |
OpenAI gpt-live-transcribe |
Estimated audio minute | $0.017 |
OpenAI gpt-realtime-translate |
Estimated audio minute | $0.034 |
OpenAI gpt-image-2.6-sunburst / gpt-image-2.6-flare image tokens |
MTok input / cached / output | $8 / $2 / $30 |
OpenAI text-embedding-3-small / text-embedding-3-large |
MTok input | $0.02 / $0.13 |
| Mistral Codestral Embed | MTok input / cached input | $0.15 / $0.015 |
Google gemini-3.5-transcribe |
Estimated blended minute | approximately $0.005 |
| Google Gemini Omni 1.2 Flash at 720p | Generated video second | $0.07 |
xAI grok-voice-3.0 |
Audio minute / text input | $0.08 / $0.004 |
| xAI speech-to-text | Audio hour | $0.10 REST; $0.20 streaming |
xAI grok-imagine-image-2.0 |
Output image, 1K–2K low/medium | $0.04–$0.08; image input adds $0.01/image |
xAI grok-imagine-video-1.5 |
Generated second, 480p / 720p / 1080p | $0.08 / $0.14 / $0.25; image input adds $0.01/image |
| Mistral OCR 4.1 | 1,000 pages | $4 standard; $0.40 cached |
| Mistral Voxtral Mini Transcribe 3, public preview | Minute | $0.0035 |
GPT-Image-2.6 text input costs $5/MTok ($1.25 cached), separate from image tokens. Do not assume every image model supports Batch because an earlier model did. Use its explicit rate card and output settings to estimate each image.
OpenAI retired the Videos API and Sora 2 models on September 24, 2026. Its self-serve fine-tuning platform is closed to new users, and active customers are scheduled to lose the ability to create jobs on January 6, 2027. Existing fine-tuned models follow their underlying base model's lifecycle. OpenAI deprecations
Embedding bills cover embedding computation, not the vector database, index rebuilding or document ingestion. Training/adaptation budgets additionally need data preparation, label review, training runs, evaluation and serving; see fine-tuning.
Common tool charges can be large enough to change model routing decisions:
| OpenAI tool | Current price |
|---|---|
| Web search | $10 / 1,000 calls, plus search-content tokens at the model rate |
| File search calls | $2.50 / 1,000 calls |
| File search storage | $0.10 / GB-day after 1 GB free |
| Hosted shell / code container | $0.03 for 1 GB, $0.12 for 4 GB, $0.48 for 16 GB, or $1.92 for 64 GB per 20-minute session |
OpenAI notes that eligible containers are billed per minute with a five-minute minimum, not necessarily one full 20-minute unit. Check actual session usage.
X Search is now billed by fetched items: $5/1,000 posts and $10/1,000 profiles. Parent and quoted posts count. It is no longer a flat per-call charge. xAI tool pricing.
DeepSeek's standalone Search and Fetch endpoints each charge $0.75 per 1,000 successful requests. An agent that searches once and fetches three pages incurs four endpoint charges plus whatever the model charges to process the retrieved text. DeepSeek Search and Fetch pricing
The Gemini rate card lists 5,000 free paid-tier Google Search grounding requests per month, shared across Gemini 3 and newer models. It then lists $14 per 1,000 queries and a daily cap of 1,500 requests for the shown plans. One model request can issue multiple queries. Measure the billed query count as well as how often grounding is needed. Google pricing
Cost Calculation
Use the provider's usage fields for metering and reconcile them with the invoice. Normalize provider-specific fields into non-overlapping billed categories; some APIs report cached input as a subset of total input. Keep rates in a dated configuration instead of hard-coding them throughout the application.
from dataclasses import dataclass
from decimal import Decimal
@dataclass(frozen=True)
class TokenRates:
input_per_mtok: Decimal
cached_input_per_mtok: Decimal
cache_write_per_mtok: Decimal
output_per_mtok: Decimal
def __post_init__(self):
for value in vars(self).values():
if not isinstance(value, Decimal) or not value.is_finite() or value < 0:
raise ValueError("rates must be finite non-negative Decimals")
def token_cost(rates, *, uncached_input=0, cached_input=0,
cache_write=0, output=0, extra_fees=Decimal("0")):
if not isinstance(rates, TokenRates):
raise ValueError("a validated rate card is required")
counts = (uncached_input, cached_input, cache_write, output)
if any(type(value) is not int or value < 0 for value in counts):
raise ValueError("token counts must be non-negative integers")
if (not isinstance(extra_fees, Decimal)
or not extra_fees.is_finite() or extra_fees < 0):
raise ValueError("fees must be a finite non-negative Decimal")
return (
uncached_input * rates.input_per_mtok
+ cached_input * rates.cached_input_per_mtok
+ cache_write * rates.cache_write_per_mtok
+ output * rates.output_per_mtok
) / Decimal("1000000") + extra_fees
GPT_6_SOL = TokenRates(*(Decimal(x) for x in ("2", "0.20", "2.50", "10")))
cost = token_cost(GPT_6_SOL, uncached_input=2_600, output=300)
print(f"USD {cost:.6f}") # USD 0.008200
This function covers token categories and explicitly supplied fees. It does not infer long-context tiers, service modifiers, cache-storage duration, media conversion, taxes, or contract terms. Select the correct rate card before calling it. Create decimals from strings, accumulate sub-cent usage, and round at the documented billing boundary. A production meter also needs bounded inputs, currency, immutable rate revisions and reconciliation records.
For an agent, calculate every turn and tool invocation. In this formula, model-call cost excludes the separately summed tool fees:
Also record abandoned runs. Excluding failures makes the cost per successful task look artificially low.
Worked Examples
RAG chatbot
Assume each request has 2,600 uncached input tokens and 300 total billed output tokens, including any billed reasoning tokens. There are no cache, tool, retry, or service-modifier charges. Actual reasoning runs may use much more output.
| Model | Cost per request | 10,000 requests/day | 30-day month |
|---|---|---|---|
| GPT-6 Astra | $0.041000 | $410.00 | $12,300.00 |
| GPT-6.1 Sol | $0.008200 | $82.00 | $2,460.00 |
| GPT-6.1 Terra | $0.004100 | $41.00 | $1,230.00 |
| Claude Opus 5.5 | $0.016400 | $164.00 | $4,920.00 |
| Claude Sonnet 5.5 | $0.008200 | $82.00 | $2,460.00 |
| Gemini 3.8 Flash, 2026 price | $0.003075 | $30.75 | $922.50 |
| GPT-6 Luna | $0.000410 | $4.10 | $123.00 |
This is arithmetic, not a model recommendation. If a lower-rate model needs more retries, produces more output, or fails the quality threshold, its cost per accepted answer can be higher.
Document summarization
For 8,000 uncached input tokens and a 500-token output using GPT-6.1 Sol:
That is $21 for 1,000 documents or $210 for 10,000 documents, before storage, retrieval, retries, and review.
Tool-using agent
Assume one run makes eight GPT-6.1 Sol calls totaling 20,000 uncached input tokens, 25,000 cached input tokens, and 4,000 output tokens, plus five OpenAI web-search calls:
| Component | Cost |
|---|---|
| Uncached input | $0.040 |
| Cached input | $0.0025 |
| Output | $0.040 |
| Five searches | $0.050 |
| Total | $0.1325 per run |
At 1,000 runs per day, the illustration is $3,975 for a 30-day month. It excludes the initial cache write, search-content tokens, containers, failed runs, and any regional or service-tier modifier.
Context Caching Economics
Caching is valuable when a sufficiently large prefix repeats within the cache lifetime. It is not automatically valuable merely because a prompt is long.
For a reusable prefix of one MTok, let:
- be the ordinary input price;
- be the cache-write price;
- be the cache-read price;
- be total uses, including the initial write.
Ignoring storage fees, caching wins when:
when $B > R$:
- OpenAI 30-minute writes and Claude 5-minute writes. A write costs 1.25 times ordinary input, so . In these tables a read costs 2.5%, 5%, or 10% of ordinary input, so , , or . One write and one complete read cost less than processing the same prefix twice.
- OpenAI 12-hour writes and Claude 1-hour writes. The OpenAI option charges . Claude charges . At the read rates above, three total uses are needed to save money. For GPT-6.1 Sol, a 12-hour write plus two reads costs , compared with for three uncached requests.
These calculations assume complete hits within the selected cache lifetime and no storage fee. The longer write can make sense when later requests arrive hours apart and would otherwise require new writes. Use measured hit counts to check the saving.
Google's explicit caching also charges token-hours of storage, so add:
Measure actual cache-hit tokens, reuse count, TTL expiry, prefix churn, and the cost of cache misses. Put stable instructions and shared documents before request-specific data when the provider's caching rules are prefix-based.
Cost Optimization
Optimize only after measuring quality and usage. The highest-leverage controls usually are:
- Measure cost per successful task. Join usage, tool fees, retries, human review, latency, and outcome quality by request or agent run.
- Shorten what is repeatedly sent. Remove redundant instructions, trim tool descriptions, summarize state, and retrieve only relevant context.
- Cache stable prefixes. Validate the realized hit rate and include cache writes and storage in the calculation.
- Use Batch or Flex for deferrable work. OpenAI, Anthropic, and Google publish 50%-lower token rates for eligible asynchronous/deferred paths, but their latency and feature contracts differ.
- Route with evaluations. Send easy work to a lower-cost model only after measuring routing errors, escalation frequency, and cost per passing result.
- Bound agents. Cap model turns, output, reasoning effort, tool calls, elapsed time, and dollars per run. Detect repeated state and tool loops.
- Use specialist endpoints. OCR, transcription, moderation, embeddings, and media generation often have better pricing and behavior than a general model forced into the task.
- Control failure amplification. Use bounded retries with jitter, idempotent tools, circuit breakers, and failure-aware fallbacks.
- Clean up billed storage. Expire unused vector stores, files, caches, and container sessions according to retention policy.
Avoid promising a fixed percentage saving from routing, caching, quantization, or prompt compression. The realized saving depends on traffic and quality.
Self-Hosting Economics
There is no universal query-count or GPU-utilization threshold at which self-hosting becomes cheaper. Compare equal-quality systems under the same latency, availability, safety, and governance requirements.
Capacity model
A first approximation is:
Here the first rate is measured during active serving and the duty fraction is the portion of wall-clock time serving this workload. If your rate is already averaged over the full interval, do not multiply by duty fraction again. GPU utilization is not the same as useful token throughput.
Benchmark the exact model, quantization, prompt-length distribution, output length, batch size, tensor parallelism, and serving stack. Prefill and decode have different bottlenecks; one average tokens-per-second number can hide tail latency and concurrency failures.
Reserved, serverless and interruptible capacity
| Capacity contract | Economic benefit | Required check |
|---|---|---|
| Reserved / committed | Predictable capacity or discounted commitment | Idle capacity, commitment length, failover headroom and cancellation terms |
| Serverless / autoscaled | Can reduce paid idle time | Minimums, cold starts, quotas, scaling speed and how active time is billed |
| Spot / interruptible | Potentially lower compute rate | Interruption probability, checkpoint/restart cost and deadline impact |
| Multiple providers / regions | More options for eligible workloads | Data placement, egress, model distribution, network latency and operational overhead |
No option has infinite burst capacity, and no universal 40% utilization crossover exists. Moving work to a cheaper region may violate residency requirements or cost more after egress and model loading. Use interruptible capacity for restartable work only when the recovery plan meets the deadline.
Memory floor: 70 billion parameters at two bytes each require about 140 GB (130.4 GiB) for weights alone. A nominal four-bit representation has a 35 GB (32.6 GiB) weight floor before scales, metadata and unquantized layers. Add KV cache, activations, runtime buffers and fragmentation. In a mixture-of-experts model, fewer active parameters per token do not mean only those weights must be stored. Benchmark the complete deployment; see quantization.
Full self-hosted TCO
Include:
- accelerator and CPU hours, including idle, failover, and capacity headroom;
- storage, networking, load balancing, orchestration, and observability;
- inference-server and model licenses;
- quantization or fine-tuning work and quality regression testing;
- security patching, abuse controls, incident response, and on-call labor;
- deployment, autoscaling, upgrades, and model migrations;
- downtime, capacity shortages, and disaster recovery.
A defensible break-even condition is:
Use current quotes for the intended hardware, provider, region, commitment, and network path. A public on-demand GPU price from another region is not a reliable production estimate.
Self-hosting can still be preferable when weight access, customization, data placement, or operational control matters more than the raw cost comparison.
Total Cost of Ownership and FinOps
FinOps is an operating practice for making technology spending accountable to business value through collaboration between engineering, finance and business teams. It includes allocation, forecasting and optimization; reducing spend alone is not the goal. FinOps Foundation framework.
Track the economic unit the product actually sells or operates:
Useful dimensions include tenant, feature, environment, model and version, prompt version, service tier, region, cache status, tool, success result, and retry/fallback reason.
Operational controls should include:
- budgets and alerts by tenant, feature, model, and environment;
- per-request usage and estimated-cost logs reconciled with invoices;
- anomaly detection for token growth, cache misses, loops, and retry storms;
- quotas and graceful degradation instead of one global hard stop;
- canary and shadow-traffic budgets;
- a dated rate-card registry with an owner and review cadence;
- invoice reconciliation for rounding, free allowances, taxes, and negotiated terms.
Forecast with complete requests so related costs stay together. For example, long document reviews might generate longer answers and call more tools. To estimate P50 and P95, calculate the total in each recorded or simulated period, then take percentiles of those totals. Multiplying the P95 input length by the P95 retry count combines values that may rarely occur together. Recalculate for changes in price, demand, cache hits, model choice, and review workload.
Manager interview practice
Mental arithmetic: 2,000 input tokens at an illustrative $2/MTok plus 500 billed output tokens at $10/MTok costs $0.004 + $0.005 = $0.009 per call. Five such calls cost $0.045 before tools, retries, and review. These are invented rates to practice units, not a provider quote.
Recall checks: Are cache writes being counted twice? Does output already include reasoning? Which context/service tier applies? Are failed attempts in the numerator? What happens to unit economics if review doubles?
Agree with the product team on what counts as a successful task. Agree with finance on which expenses to include. Save the rates and effective dates used for each forecast so you can recalculate when prices change.
Hypothetical API versus self-hosted TCO worksheet
Assume one million completed tasks/month of equal accepted quality. For teaching arithmetic only, suppose the API costs $0.008/task for model calls and the self-hosted serving fleet can support this workload at its measured latency target. These are invented rates, not current vendor prices.
| Monthly cost | API option | Self-hosted option | Assumption |
|---|---|---|---|
| Model calls or active GPU fleet | $8,000 | $6,000 | API scales with tasks; reserved GPU capacity is largely fixed |
| Standby/redundancy | Included in API rate here | $3,000 | Spare capacity for a replica failure |
| CPU, storage, networking | $1,000 | $2,000 | Application and serving overhead |
| Engineering/on-call allocation | $3,000 | $8,000 | Loaded labor allocated to this service |
| Evaluation and review | $2,000 | $2,000 | Same assumed accepted-quality target |
| Total | $14,000 | $21,000 | Migration cost excluded and reported separately |
| Cost/completed task | $0.014 | $0.021 | One million completed tasks, including unsuccessful-attempt cost in totals |
At 500,000 tasks, assume API model spend halves while its other lines stay fixed: $10,000 total, or $0.020/task. If the self-hosted fleet cannot shrink, $21,000 becomes $0.042/task. At two million tasks, the API becomes $22,000. Self-hosting is $0.0105/task only if the existing fleet can actually handle that demand and failure headroom; otherwise add the required capacity. The apparent break-even under fixed non-model assumptions is (21,000 − 6,000) / 0.008 = 1.875 million tasks/month, conditional on that capacity.
Idle and reserved capacity are already paid for in the GPU lines; do not add “idle cost” a second time. Measure utilization to explain why cost per task rises at low volume. Add one-time migration, compliance, tooling, and retraining costs over an explicit amortization period when relevant. For unequal quality, compare total cost per verified outcome rather than equal raw request counts.
Forecast the workload and test the boundary cases
A rate change can affect the whole request. With no cache or other fees, GPT-6.1 Sol at 272,000 input tokens and 1,000 billed output tokens costs 272000 × 2/1M + 1000 × 10/1M = USD 0.554. At 272,001 input tokens, the long-context rates apply: 272001 × 4/1M + 1000 × 15/1M = USD 1.103004. One added token crosses a billing boundary; do not estimate this as one extra token at the old rate.
For caching, use the strict inequality in the earlier section. At illustrative rates B=2, W=2.50, R=0.20 per MTok, a reusable one-MTok prefix costs:
| Total uses within the eligible lifetime | Without caching | One write, remaining uses hit | Saving |
|---|---|---|---|
| 1 | USD 2.00 | USD 2.50 | −USD 0.50 |
| 2 | USD 4.00 | USD 2.70 | USD 1.30 |
| 3 | USD 6.00 | USD 2.90 | USD 3.10 |
| 5 | USD 10.00 | USD 3.30 | USD 6.70 |
These are invented rates for isolating cache arithmetic, not a one-MTok short-context provider quote. Add storage and rewrite costs when they apply. If B ≤ R and W ≥ B, caching cannot reduce this token bill; the break-even expression requiring B > R is not applicable.
Traffic mix example: suppose 80% of tasks cost USD 0.005 and 20% cost USD 0.050, including their own calls and tools. Mean variable cost is 0.8 × .005 + 0.2 × .050 = USD 0.014, so 100,000 tasks cost USD 1,400. If the expensive slice rises to 40%, cost becomes USD 2,300, an increase of about 64.3%, with no rate or volume change. Preserve this correlation in the forecast.
Interview: design a cost-control service
Scope. Track usage and enforce budgets for an application that calls several model APIs. Keep an internal ledger that shows how much each tenant and feature spent. Compare those records with the provider’s invoice to find and resolve differences.
Functional requirements
- Attribute each model/tool execution to an authenticated tenant, product feature, environment and task.
- Select a versioned rate contract by provider, model, service, region and effective time.
- Reserve budget before admitting work and settle against observed usage.
- Include retries, failed tasks, storage, evaluations and human-review allocations in reports.
- Compare late usage records and invoices with the ledger. Record corrections separately so earlier entries can still be audited.
Non-functional requirements
- Concurrent workers cannot each spend the same unreserved balance.
- If a usage event arrives twice, charge it once. Keep a separate record for each actual call to the provider.
- Show missing usage as unknown until records arrive that confirm what the provider charged.
- Limit tenants to their own usage records. Keep prompt contents and credentials out of those records.
- At the peak estimated below, target a p95 budget check under 20 ms and 99.9% availability for the service that admits requests. Test with one tenant generating a large share of the traffic. Set a queue limit and decide what happens when the ledger is unavailable.
Initial design. Each worker reads the tenant’s remaining budget, calls the model, then subtracts an estimate. This creates three problems:
- Two workers can both see the same balance and spend it at the same time.
- A worker can crash after the provider charges for the call but before the worker records the usage.
- A stream can disconnect before the provider sends the final token counts.
A nightly report can reveal overspending after it happens. To prevent it, reserve budget before the call.
Detailed design
Read diagram source
flowchart TB
U["Authenticated task and bounded execution plan"] --> A["Admission service: tenant budget + policy"]
R[("Versioned rates and billing contracts")] --> A
A --> B[("Atomic reservation and task ledger")]
B -->|Reservation committed| E["Execute bounded model / tool attempt"]
E --> P["Provider / external tool"]
P --> M["Usage adapter: disjoint units + actual tier"]
M --> Q["Durable usage event stream"]
Q --> S["Idempotent settlement / adjustment"]
S --> B
E -->|Outcome or usage unknown| H["Hold reservation; reconcile with provider"]
H --> S
I["Invoice / usage export"] --> C["Reconciliation and discrepancy review"]
C --> S
B --> D["Tenant allocation, forecasts and alerts"]
D --> O["Reviewed policy / routing change"]
O --> A
Data and API contract
| Record / operation | Required identity and behavior |
|---|---|
POST /reservations |
Tenant from authentication; unique operation ID, planned maximum exposure, currency, budget period and rate revision |
| Execution attempt | Task ID plus unique attempt ID; model revision, requested/actual tier, provider request ID and outcome |
| Usage event | Unique event identity, unit/category, quantity, observation time and whether cumulative or incremental |
| Settlement | Consume the matching reservation once; charge recorded actual usage and release only the known excess |
| Adjustment | Append a reasoned correction linked to the earlier entry and provider evidence |
| Cost report | Include settled amounts, outstanding reservations, unknown usage and allocation coverage separately |
Example: two workers share one budget.
- The tenant has a USD 10 limit. It has spent USD 9.50 and reserved USD 0.10 for work in progress, leaving USD 0.40 available.
- Two workers each ask to reserve USD 0.30. The ledger checks and reserves the balance in one atomic operation. Once the first reservation succeeds, USD 0.10 is left, so the second request must wait or be rejected.
- With multiple regions, send reservations for that tenant to one ledger owner or split the budget into regional allowances. If each region sees a delayed copy of the full balance, they can collectively exceed it.
Example: settle the reservation after the call.
- Set aside USD 0.30 before dispatch. If the provider reports USD 0.18 of usage, record that charge and return USD 0.12 to the available budget.
- If the final usage is missing, keep the reservation until provider records confirm the charge. Another worker may take over after the original worker's lease expires, but the first call may already have incurred charges. Pause further expensive work when you cannot account for the earlier call or fund the next one.
- Record refunds and billing corrections as new entries linked to the original charge. This lets you explain how the balance changed.
To enforce a hard cap, reserve enough for the most the call can cost. Limit input and output tokens, tool calls, loop iterations, and run time. Use only approved services and budget for the uncached rate if you cannot predict a hit. If a provider can charge beyond those limits, define what happens when the reported bill exceeds the reservation. Canceling a call can stop future work, but charges for work already done may still arrive.
Capacity estimates
- Calls: 100 admitted tasks per second × 3 model calls per task = 300 calls per second, before retries and background tests.
- Writes: One reservation and one settlement per call require about 600 ledger writes per second. Allow extra capacity for usage events and corrections. Check whether a single high-volume tenant can overload the partition that holds its balance.
- Storage: 9 million attempts per month × 1 KB per usage record = 9 GB per month of raw records, before replicas, indexes and event metadata. Keep prompt traces under a separate privacy and retention policy.
| Flaw or change | Benefit of the repair | Cost / remaining tradeoff |
|---|---|---|
| Independent workers overspend | Atomic reservation protects a shared budget | Added latency and contention for a hot tenant |
| Every token stream update is summed | Normalize cumulative counters; settle final or corrected usage once | Provider-specific adapters and retained revisions |
| Duplicate event vs duplicate execution confused | Deduplicate event identity, preserve real attempts | More records; cannot erase external charges |
| Old requests use today’s price | Pin effective contract and append invoice adjustments | Rate registry and audit work |
| Cache estimate assumes every call hits | Reserve worst permitted uncached exposure, settle actual categories | Temporarily lower usable budget |
| Budget ledger is unavailable | Pause new expensive work or use preallocated bounded allowances | Availability tradeoff; no unlimited bypass |
| Global cutoff affects all customers | Tenant budgets and prioritized graceful degradation | More policy and operational complexity |
| Spending drops because quality drops | Join cost with verified outcomes and reviewer effort | Delayed labels and sampling cost |
Full cost and benefit calculation
For a smaller product example, assume 100,000 tasks/month. These rates and workloads are invented:
| Monthly item | Baseline | Proposed routing and cost controls |
|---|---|---|
| Model calls | 3/task × USD .009 = USD 2,700 | 2/task × USD .006 = USD 1,200 |
| Tools | USD .005/task = USD 500 | USD .004/task = USD 400 |
| Human review, 3 minutes at USD 60/hour | 5% of tasks = USD 15,000 | 6% of tasks = USD 18,000 |
| Common application operations | USD 2,000 | USD 2,000 |
| Incremental metering operations | — | USD 500 |
| Setup amortized over six months | — | USD 3,000 / 6 = USD 500 |
| Total | USD 20,200 | USD 22,600 |
Read diagram source
xychart-beta
title "Illustrative monthly total cost"
x-axis [Baseline, Proposal]
y-axis "USD per month" 0 --> 25000
bar [20200, 22600]
The model/tool bill falls 50%, yet TCO rises USD 2,400/month because reviewer work and new operating costs outweigh the saving. If both workflows produce 95,000 verified accepted outcomes after review, cost per 1,000 accepted outcomes rises from about USD 212.63 to USD 237.89. Equal accepted quality is an assumption to verify, not a consequence of human review.
Holding other lines fixed, the proposal breaks even at 5,200 reviewed tasks, or a 5.2% review rate. At 5%, it costs USD 19,600 and saves USD 600/month. That narrow margin needs production validation. The meter may still be justified for attribution and budget control even when a particular model-routing change fails its economic test; evaluate those decisions separately.
Launch checks
- Give every provider call its own ID. Verify that duplicate events charge once, simultaneous requests cannot spend the same balance, and missing usage is visible in the report.
- Compare the ledger with provider invoices and assign someone to resolve each discrepancy. Check whether tenants with heavy traffic can still reserve budget within the latency target.
- Compare routing options at the same quality target. Include any change in human review and report total cost per successful task. Keep the previous routing rules available so you can switch back if quality or cost gets worse.
Interview questions with developed answers
Q1: How would you optimize a high-volume RAG application's cost?
Show answer and follow-up
- Break down spending by document ingestion, retrieval, model calls, tools, retries, and human review. For each completed task, record the calls, tokens, cache hits, and outcome.
- Test a change to the largest cost you can reduce. For example, remove duplicate calls, retrieve fewer passages if they still cover the answer, or batch work that can wait.
- Check that answers remain correct and current and that users only see documents they can access. Compare total cost per successful task before and after the change.
Follow-up: Why not shorten every answer? Missing explanations can increase user confusion and human rework.
Q2: When would you recommend self-hosting instead of APIs?
Show answer and follow-up
- Compare deployments that meet the same quality, latency, availability, security, and data requirements. A requirement to keep data in your own environment can decide the question before you compare prices.
- For self-hosting, count active and idle GPUs, backup capacity, serving software, and staff time for upgrades and incidents. For an API, count model usage, tools, service-tier fees, and the cost of running your application.
- Run both options against a realistic traffic mix. Recalculate with lower demand and different API prices. A fleet that is economical at steady traffic can cost more per task when its GPUs sit idle.
Follow-up: What if the open model needs more retries? Include those attempts and their quality impact in the comparison.
Q3: How do you avoid double-counting cache and reasoning tokens?
Show answer and follow-up
- Check what each provider usage field includes. If total input includes cached input, subtract cache hits from total input before applying the uncached rate.
- If billed output already includes reasoning tokens, apply the output rate to that total once. Add separately billed charges such as cache storage or tools as their own line items.
- Compare the estimated charges with the invoice to catch billing categories your calculation missed.
Follow-up: Can the same visible answer cost different amounts? Yes, because input, reasoning, retries, service tier, and caching can differ.
Q4: Why can a cheaper per-token model be more expensive overall?
Show answer and follow-up
The cheaper model may need more context, retries, or human review to complete the same task. Test both options on the same requests. Add the costs of successful and failed attempts, tools, and review, then divide by the number of verified successful tasks. Check severe failures separately. For example, an option that exposes private data fails the access requirement even if it costs less.
Follow-up: What if review cost is paid by another team? It still belongs in an agreed whole-workflow comparison.
Q5: How do you budget when provider prices change?
Show answer and follow-up
- Record the rates your account pays and their effective dates. Use the provider’s published rates for standard pricing and your contract for any negotiated rates or commitments.
- Recalculate the monthly bill under the current rates, announced changes, and a higher-cost scenario. Include changes in request volume, cache hits, and the number of tasks that need human review.
- Before committing to reserved capacity or self-hosting, check the cost if demand falls or the API gets cheaper. Test any replacement on the same tasks to see whether it still meets the quality and latency targets.
Follow-up: What if a current rate is unavailable? Use a labeled assumption for scenario planning and confirm the rate before using it to choose a provider.
Q6: The API reports 10,000 input tokens including 8,000 cached tokens. What is billed?
Show answer and follow-up
Apply the uncached rate to 2,000 and the cache-read rate to 8,000, under that stated usage contract. At USD 2/MTok and USD .20/MTok, input costs USD .0056. Add 1,000 output tokens at USD 10/MTok and the total is USD .0156. Cache writes/storage, if separately charged, remain explicit.
Follow-up: What if another provider’s input field excludes cache creation? Use its documented usage fields and charge cache creation separately if the provider bills for it.
Q7: One extra prompt token nearly doubles an example bill. Is that a calculation bug?
Show answer and follow-up
It can be a whole-request pricing threshold. The GPT-6.1 Sol example goes from USD .554 at 272,000 input tokens to USD 1.103004 at 272,001 with the same 1,000 billed output tokens. Apply the correct tier to the full request, then any eligible service/region modifiers.
Follow-up: Should you always trim below the threshold? Only if the removed context is unnecessary or an alternative architecture preserves required quality.
Q8: A prefix is used once before expiry. Does a 90% read discount save money?
Show answer and follow-up
The first use writes the prefix to the cache. If the write costs 1.25 times the ordinary input rate and the prefix expires before any reuse, caching increases the bill. Estimate how often the same prefix is requested again before expiry, how often it changes, and whether storage has a separate charge. Apply the discount to tokens read from the cache.
Follow-up: Can a semantic answer cache replace this calculation? It is a different mechanism with its own correctness, authorization and invalidation requirements.
Q9: Why can two small requests exceed a tenant’s remaining budget?
Show answer and follow-up
If workers independently read the same balance and only subtract after completion, both can spend it. Reserve exposure atomically before dispatch, then settle actual usage and release the known excess. Two USD .30 requests cannot both fit in a shared USD .40 balance.
Follow-up: Can asynchronous cross-region counters enforce one strict global cap? Not without coordination or bounded budget allocations that account for all regional spending.
Q10: A stream disconnects without final usage. What cost should the report show?
Show answer and follow-up
Show the confirmed charges and flag the missing amount as unknown. Keep the reserved budget until the provider confirms the final usage. The model may have continued generating or using paid tools after the client disconnected. If you release the budget on every timeout, retries can exceed the limit.
Follow-up: Is this a free retry? No. A new execution can incur another charge even if our result storage deduplicates it.
Q11: A usage stream reports cumulative counts 100, 250 and 400. Is the total 750?
Show answer and follow-up
No, if these are snapshots of the same category and attempt: final cumulative usage is 400. Incremental deltas would be a different contract. Preserve event identity and revision, select or derive counters according to the provider schema, and avoid counting final totals on top of already settled increments.
Follow-up: What if final usage corrects an earlier amount? Add a correction that links to the original charge and the provider record showing the revised amount.
Q12: Model and tool spending falls by half. Why might finance reject the optimization?
Show answer and follow-up
The worked comparison reduces those lines from USD 3,200 to USD 1,600, but review rises from USD 15,000 to USD 18,000 and new operations/setup add USD 1,000 monthly. Full cost rises from USD 20,200 to USD 22,600. Compare matched accepted outcomes and the entire agreed cost boundary.
Follow-up: At what review rate does this proposal break even? 5.2% with the other costs in this example held fixed.
Q13: When do nine million usage records require more than nine GB?
Show answer and follow-up
Nine million one-kilobyte records are about nine decimal GB of raw payload. Replication, indexes, envelopes, metadata and retained revisions add storage. Prompt bodies and traces may be far larger and should have their own access and retention rules. Estimate ingestion and queries as well as bytes.
Follow-up: How do you add a monthly storage fee? Count it once in the monthly total. If you need a per-task estimate, divide that fee across the tasks it serves.
Q14: A serverless GPU is cheaper per hour. Why can a reserved fleet still win?
Show answer and follow-up
The contracts differ. Compare billable active time, minimums, cold starts, required availability, scaling quotas and sustained demand. A reserved fleet can be efficient at steady load but costly when idle; serverless can still need warm capacity. Include retries and restart costs for interruptible instances.
Follow-up: Does a low-parameter MoE guarantee a small memory footprint? No. Active compute per token and resident weight memory are different quantities.
Q15: How would you forecast a bill after the traffic mix changes?
Show answer and follow-up
Group tasks by how they use the system. Estimate the share of each group and the average cost of its full request, including input, output, tools, and retries. In the example, increasing the share of USD .050 tasks from 20% to 40% raises the bill for 100,000 tasks from USD 1,400 to USD 2,300 even at the same rates. Run a separate forecast for announced price changes so you can see what caused the increase.
Follow-up: Is multiplying every P95 input a P95 total forecast? No. Marginal percentiles do not determine a joint percentile or the monthly mean.
Final recall table and notes
| Decision | Evidence to bring |
|---|---|
| Estimate a task | Count calls and tools. Apply dated rates to each billed unit once. |
| Approve caching | Measure how often data is reused before expiry. Include write and storage fees and check permissions and freshness for cached answers. |
| Enforce a budget | Reserve the maximum cost before dispatch. Check reported charges and keep missing usage visible. |
| Switch a model | Compare cost per successful task at the same quality target. Define when to switch back. |
| Self-host | Measure how many requests the fleet can serve within the latency target. Include memory, spare capacity and staff costs. |
| Sign a commitment | Demand scenarios, contract terms, migration cost and price-change risk |
Show the units in each calculation. A rate card gives the price per unit, a forecast applies those prices to expected usage, and a TCO comparison adds the cost of running each option.
60-second interview answer
- Count every model call, tool, retry, and review step needed to finish a task. Apply the rates for the model, context size, service tier, and region you use.
- Compare the estimates with billed usage. Then divide total cost by verified successful tasks and check quality and latency against the requirements.
- Recalculate when traffic, rates, or review workload changes. An option with cheaper tokens can cost more per task if it needs more calls or human corrections.
For each billed unit, multiply the rate by usage. Then add tool fees, rework, and operating costs.
Official Sources
Next checks
| Date / trigger | Recheck |
|---|---|
| Nov. 30, 2026 | Current rate-card end date for GPT-5.6 Sol's promotional price. Recheck the subsequent rate. |
| Dec. 1, 2026 | Announced Gemini 4 Argon standard rate changes. |
| Jan. 1, 2027 | Announced Gemini Flash price and cache-storage increases |
| Every release or contract change | Model IDs, availability, rates, regions, tiers, free allowances and examples |
| Each invoice | Reconcile provider-metered usage and contract adjustments with internal estimates |
Selected API rate cards and release notes checked November 10, 2026:
- OpenAI API pricing
- Anthropic Claude API pricing
- Google Gemini Developer API pricing
- Google Gemini Omni 1.2 Flash launch pricing
- xAI API pricing
- Mistral API pricing
- Mistral Large 4 model card and Voxtral Mini Transcribe 3 model card
- DeepSeek models and pricing
Next: Model Selection Guide