Back to Writing

AI costs

What Is Inference Cost? A Guide for LLM Startups

Learn how to calculate LLM inference cost per request and per task, forecast monthly spend, and reduce token costs without sacrificing output quality.

11 min read

Key takeaways

  • Inference cost is the per-token price you pay on every model request, and it is usually an LLM startup's largest variable expense.
  • Per-request cost equals input tokens times input price plus output tokens times output price, with output tokens priced higher.
  • Agent loops, retrieval bloat, and retries multiply token counts, so track cost per completed task rather than per request.
  • Estimate monthly spend bottom-up from tasks per user, tokens per task, and blended price per token, then add 20-30% for retries and evals.
  • Most savings come from sending fewer tokens: trim prompts, cache repeats, use batch endpoints, and route easy tasks to cheaper model tiers.

Inference cost is what you pay every time your product runs a model: a per-token rate applied to the prompt and completion of each request. It is usually your largest variable expense in production, and it shifts as providers reprice models and release cheaper tiers. This guide shows how to compute it per task and forecast your token bill before real users do.

What is inference cost in AI?

Inference cost is what you pay a model provider, or spend on your own hardware, every time your product runs a prompt through an LLM. It is the per-request cost of generating output, priced per token, and it recurs with every user action.

Inference cost meaning: compute, not training

Training cost is a one-time capital expense; inference cost is your unit economics. Each request consumes input and output tokens, and providers bill both. OpenAI's current per-token rates, plus batch and caching discounts, are published on their pricing page. Rates differ by model, so architecture choices move the number.

Where founders hit it first: the token bill after real users arrive

Demos hide inference cost because volume is low. Real traffic multiplies it: every chat turn, retrieval call, and agent step adds tokens. Founders usually discover the gap when the first monthly invoice lands, not in testing. For worked models of that bill, see Writing.

How is LLM inference cost calculated per request?

Tokens in, tokens out: the pricing formula

Every request is billed as (input tokens × input price) + (output tokens × output price). Input and output tokens are priced separately, with output almost always costing more. A request that retrieves 2,000 tokens of context and generates 300 tokens of answer pays for all 2,300, even though only 300 shape what the user sees.

Worked example: cost per task for a RAG query

Say your RAG pipeline sends a 2,000-token prompt (system prompt, retrieved chunks, user question) and the model returns a 300-token answer. Using illustrative rates of $3 per million input tokens and $15 per million output tokens, the math looks like this:

ComponentTokensRate (per 1M)Cost
Input (prompt + context)2,000$3$0.006
Output (answer)300$15$0.0045
Total per request2,300$0.0105

At 10,000 requests a day, that single task type costs roughly $105 daily, or about $3,150 a month, before retries and agent loops multiply the count.

Cached vs uncached input tokens

Most providers charge less for input tokens repeated across requests, since a cached prefix skips recomputation. If your system prompt and retrieved context are stable, cache hits can cut input cost substantially. Design prompts so the unchanging parts come first, and measure your cache hit rate before assuming the uncached rate applies to your bill.

How does GPT-3 inference cost compare to current model pricing?

Published GPT-3 pricing at launch

When OpenAI opened the API in 2020, GPT-3 was priced at roughly $0.06 per 1,000 tokens on its largest davinci model, with smaller variants priced lower (OpenAI API announcement). That was the only option: one vendor, one pricing curve, and no cheap tier to fall back on.

What the same budget buys today

Current OpenAI pricing (published on OpenAI's pricing pages) lists smaller models at fractions of a cent per 1,000 tokens, so a task that cost a few dollars on davinci can now run for pennies on a mini-class model. The gap is roughly two orders of magnitude per token, though exact figures shift as OpenAI reprices.

The practical takeaway: GPT-3-era cost models are obsolete. If your unit economics were sketched against launch pricing, rerun them against the current price list and the cheapest model that passes your evals before you commit to an architecture.

Why does inference cost change over time?

Inference cost is not a fixed property of your product. It moves whenever a provider reprices a model, retires one, or introduces a new pricing tier, and your per-task cost model can shift overnight without a single code change.

Model deprecations and replacement pricing

Providers retire older models, and the replacement rarely matches the old price or the old token efficiency. A deprecation notice usually gives you a migration window, after which your only options are the successor model or a different provider. Re-run your cost model against the replacement before that window closes, because a successor with a longer system prompt or higher output tokens can raise your token bill even at a similar per-token rate.

Tier changes: batch, caching, and volume discounts

Providers add pricing tiers after launch: discounted batch processing, cached-input rates, and volume commitments. Each one changes your effective cost per request, not just your list rate. A workload that is too expensive at launch prices can become viable six months later through batch or caching tiers.

A timeline of published pricing shifts

Published prices for the same model family have dropped repeatedly since GPT-3's launch, and new tiers have appeared alongside those cuts. The practical takeaway: treat your inference cost as a quarterly re-forecast, not a one-time calculation, and keep your per-task cost model in a place where swapping a rate is a one-line change.

What drives AI inference cost beyond the per-token rate?

The per-token rate is the sticker price. Production bills are set by how many tokens you actually send, and three habits inflate that number fast.

Retrieval bloat: prompt sizes that grow with context

RAG pipelines tend to over-fetch. If retrieval returns ten chunks where two would answer the question, you pay for eight chunks of noise on every request. Prompt size also creeps as teams append instructions, examples, and conversation history "just in case." A prompt that doubles from 2K to 4K tokens doubles your input cost per call without improving output quality, and it slows latency too. Audit what actually reaches the model, not what your retriever could return.

Agent loops: multi-step tasks that multiply requests

A single agent task is rarely one call. Plan, retrieve, call a tool, reflect, retry: five steps means five paid requests, each carrying the accumulated context from the ones before it. A task that looks like $0.02 per call can quietly cost $0.10 once you count the loop. The fix is architectural: cap loop iterations, trim context between steps, and log tokens per step so you can see which stage burns the budget. Teams that skip this step-wise accounting usually discover the imbalance only after the token bill arrives, because dashboards that report cost per request hide cost per task, and cost per task is the number your unit economics actually depend on.

Retries, evals, and shadow traffic

Retries on rate limits, nightly eval runs, and shadow deployments all consume tokens without serving a user. Model deprecation adds another cost: when a provider retires a model, you pay to re-test and migrate, as OpenAI documents in its deprecation notices listing retired models and dates. Budget for this overhead explicitly, or it will show up as a "mystery" line item.

How do you estimate monthly inference cost before shipping?

A bottom-up model: tasks per user, tokens per task, price per token

Build the estimate from three numbers: how many tasks each active user runs per day, how many tokens each task consumes (input plus output), and the blended price per token across the models you call. Multiply them out, then multiply by active users per day and days per month.

A worked example: 500 daily active users, 10 tasks per user per day, 2,000 tokens per task, at a blended $3 per million tokens. That is 500 × 10 × 2,000 = 10 million tokens per day, or about $30 per day and roughly $900 per month. If half your traffic routes to a more expensive model, recompute the blended rate rather than guessing.

Add 20-30% for retries, failed generations, and eval runs, which burn tokens invisibly.

Stress-testing the estimate with a 10x traffic scenario

Rerun the model at 10x users. Your $900 month becomes $9,000, and per-task cost now decides whether unit economics work. If a paid user generates $20 of monthly revenue but 10x traffic implies $18 of inference cost, the architecture needs changing before you scale, not after.

How can teams reduce inference cost without switching models?

Most production savings come from sending fewer tokens, not from downgrading models. Start with prompt and retrieval trimming: cut dead instructions, cap retrieved chunks, and drop history that does not change the answer. Since tokens are the billing unit, and providers define a token as roughly four characters of common English text (OpenAI help center), every paragraph you trim is a direct cut to inference cost on both input and output.

Caching and batch endpoints attack repeat traffic. Cache identical or near-identical queries so a repeated question costs zero, and route non-urgent jobs like nightly summarization through batch APIs, which providers typically price below synchronous calls.

Finally, route easy tasks to cheaper tiers. Classify each request, send short lookups or simple extractions to a smaller model in the same family, and reserve the flagship model for the calls that actually need it. Teams routinely move 60-70% of traffic to cheaper tiers this way, though that split is illustrative and depends on your workload.

When does inference cost signal an architecture problem?

A rising token bill points to architecture when cost per task climbs while output quality stays flat. If the same user request costs 3x more tokens than it did last quarter, the fix is usually retrieval, context trimming, or orchestration changes, not a cheaper model.

Cost per task as a reliability metric

Track tokens and dollars per completed task, not per request. When cost per task drifts upward, it usually means your agent is retrying, re-reading the same context, or calling the model more often to compensate for unreliable retrieval. That is an architecture smell first and a pricing problem second.

Tracing spend to the request level

Request-level tracing shows which step in your pipeline burns the tokens. Without it, you are averaging away the one expensive call that dominates your bill. Trace every span, attach a cost attribute, and fix the worst span before you renegotiate anything with a model provider.

FAQ

How much does OpenAI charge per token right now?

Rates vary by model and change as OpenAI reprices, so the only reliable source is their published pricing page. Smaller models cost fractions of a cent per 1,000 tokens, while flagship models cost more, and batch and cached-input discounts lower the effective rate. Check the current list before committing to an architecture.

Is inference cost per token the same for input and output?

No. Output tokens are almost always priced higher than input tokens. A RAG request that sends 2,000 input tokens and generates 300 output tokens pays two separate rates, and the output rate can be several times the input rate. Any cost model that blends them into one number will misprice your bill.

What is a token, and how many tokens is a typical prompt?

A token is the billing unit providers use, roughly four characters of common English text, so a paragraph is typically 50 to 100 tokens. A RAG prompt with a system prompt, retrieved chunks, and a user question commonly runs 2,000 tokens or more, and prompt size creeps upward as teams append instructions and history.

Do I pay for failed or retried inference requests?

Yes, in practice. Retries after rate limits, failed generations, and eval runs all consume tokens without serving a user. That overhead is why a bottom-up estimate should add 20-30% on top of projected usage. Log tokens per step so retries show up as a visible line item instead of a mystery on the invoice.

How much cheaper is batch pricing than real-time inference?

Batch endpoints are typically priced below synchronous calls, though the exact discount varies by provider and changes over time, so check the current rate card. Route non-urgent jobs like nightly summarization through batch. Combined with caching and routing easy tasks to cheaper tiers, it can make a workload viable.

Got an AI system that works in the demo but not in production?

Book a call