All blogs
12 mins
LLM Token Cost: How to Calculate and Reduce AI Spend
Piyush-Kalra
I've watched teams budget an AI feature from a provider's rate card, only to see the actual bill come in much higher once it reached production traffic. The gap wasn't a pricing mistake. It was a scope mistake; they priced the request they imagined, not all the requests their system actually made.
If you're trying to understand what your AI workloads really cost and where that spend is going, this article will walk you through how LLM token pricing works, how to calculate your actual token costs, what drives those costs up, and how to reduce both token and infrastructure spend.
What Is LLM Token Cost?

A token is a small unit of text or data. Language models view and process text characters one token at a time. One token can also be a single punctuation mark, a word, or a part of a word. A standard estimate for English is about 4 characters, or 0.75 words, per token (however, this figure is highly dependent on the model and encoding).
Price per token (LLM token cost) refers to the cost associated with the tokens the provider charges. Input tokens are the tokens the user inputs to the model, and output tokens are the tokens the model outputs. Many providers give quotes specific to a cost per million input tokens and a cost per million output tokens. Some also quote a cost per million cached input tokens.
Why do input and output tokens cost differently?
Providers usually set a higher price for output compared to input. This is likely because output is generated sequentially, and for input, much of the work can be done in parallel. The price differential will differ for different providers and models.
What about cached tokens?
Cached tokens are those that can be reused. Input tokens that are cached are significantly reduced compared to usual input tokens for a given model. The pricing differentials will vary for different providers and models. For example, currently, OpenAI has cached input for certain models at 90% of standard input, and DeepSeek has pricing for cached input that is substantially below pricing for uncached inputs.
The important limitation for cached inputs is that caching is model-dependent and so is the specific structure of your inputs. Context that is stable and does not change is usually easier to cache than inputs that are highly unpredictable and change frequently.
How Does LLM Token Pricing Work in Practice?
LLM token pricing is generally charged per million tokens, with separate charges for input, output, and sometimes cached input. Pricing is broken down by model, provider, and pricing tier.
Model | Input $/M | Output $/M |
DeepSeek V4-Flash | $0.14* | $0.28* |
Gemini 3.5 Flash-Lite | $0.30 | $2.50 |
GPT-5.4 Mini | $0.75 | $4.50 |
Claude Sonnet 5 | $2.00 | $10.00 |
GPT-5.6 Sol | $4.00† | $20.00† |
* DeepSeek now uses peak/off-peak pricing, so actual rates can be higher.
† OpenAI's GPT-5.6 Sol promotional pricing is currently $4/$20 and is scheduled to last at least through November 21, 2026.
LLM token pricing is complex, and keeping track of these numbers is unlikely to save you money. The more important number to know is the prompt length, as LLM token usage depends on user prompts and system instructions. Other factors include retrieved context, conversation history, definitions of LLM tools, and the data sent to the model.
How Do You Calculate LLM Token Cost?

LLM token costs can be broken down into two parts using the equation:
LLM cost = (input tokens × input price) + (output tokens × output price)
Example, one request: Assuming prompt length determines usage, say a support bot sends 5,500 input tokens (system prompt, context retrieved, and user message) to this model priced at $2/M input and $10/M output, which results in 400 output tokens.
Input cost: 5,500 × $0.000002 = $0.011
Output cost: 400 × $0.00001 = $0.004
Total = $0.015 per request
Example, monthly spend: Multiply that per-request cost by volume. At 50,000 requests a month, $0.015 per request becomes $750 per month.
Example, monthly spend: If the cost is incurred 50,000 times in a month, then the per-request cost is $750 per month.
Accounting for caching: For this example, let’s say 4,000 input tokens are cached and the provider charges 90% less for cached input. The cost of those tokens would be $0.0008 each. This section is based off of 50,000 requests each month and would save about 48% of the example’s total spend, costing $360 per month. Actual cache costs and the amount saved by the cache will vary by the provider and the model.
Cost per task: After you are running production workloads, the cost per million tokens is not always the best categorization of cost. The cost per task is the total cost of the LLM divided by the number of tasks completed. Two models with the same per-token rate can still have very different costs per task, depending on how the application is built and the consumption of tokens
Why Your Real LLM Cost Is Higher Than the Token Price

The token price is only part of the calculation. In production, several layers can add to your token usage without appearing in the user's visible message:
System prompts are converted to input tokens and are included in the cost when a request is made.
Systems can remember conversation history, which can lead to constantly growing context and input usage.
RAG models require a document to be sent along with the request.
Tool integration may result in additional calls to the model, which would slightly increase input and output usage.
Agentic workflows use models in a chained manner. The subsequent step in the workflow may use the context of a previous step.
Retries and validation loops can consume additional tokens without producing additional completed work.
Reasoning tokens are utilized by some models for internal reasoning. These tokens are not exposed to the user, but OpenAI still counts them under output usage and charging.
Agent workloads may quickly incur a significant cost. For example, imagine a 12-step workflow that starts with 2,000 tokens of context and adds an additional 1,000 tokens after each subsequent step. If each step sends the context, the total cost is:
12 × 2,000 + 1,000 × (0 + 1 + ... + 11) = 90,000 tokens
This is much more than the anticipated cost of 24,000 tokens for 12 requests, each with a context of 2,000 tokens.
The price is not just the number of calls to the model. You have to think about how much context each call processes as well.
What Drives LLM Token Costs Up?
Cost driver | Why it increases cost |
Large prompts | More input tokens per call |
Long conversation history | Repeated context on every turn |
Large RAG payloads | More retrieved tokens per query |
Verbose outputs | More output tokens, often billed at a higher rate |
Agent loops | Multiple model calls per user action |
Expensive models | Higher token rates |
Retries | Duplicate token consumption for no net gain |
High request volume | Small per-request costs compound quickly |
The prompt size, output size, context bloat, model calls, and retries are the levers most controllable by teams. Request volume is to some degree a function of demand, but a lot of extra calls can be eliminated by better design of the workflow, caching, batching, and model routing. As a result, the cost-saving strategies discussed below will focus on the aspects of token consumption that are actually under the control of the teams.
8 Ways to Reduce LLM Token Costs
Reduce unnecessary input context: Strip instructions, history, and other content that was retrieved, is redundant, or is not relevant to the current question.
Limit output length: Set appropriate output-token limits and use a structured response. This will prevent the model from generating a response that is longer than necessary to complete the task.
Use prompt and context caching: Move all reusable content to the start of the prompt. This includes instructions, tool definitions, and any other content that is fixed. Providers have different rules for caching, so check the caching instructions.
Optimize RAG context: Retrieve only what is necessary to complete the task. Sending unnecessary context increases input token consumption.
Choose the right model for the task: Use less expensive models for straight classification and extraction while reserving more powerful models for more complex tasks.
Batch non-urgent workloads: OpenAI's Batch API offers a 50% discount over synchronous pricing for supported tasks for asynchronous evaluation, classification, and summarization.
Control agent loops and tool calls: Avoid redundant iterations and omit context that subsequent steps are unlikely to need. Agents will resend instructions, definitions, and previous outputs repeatedly and consume tokens unnecessarily.
Monitor token usage by workload: Track spend by application, feature, and task, not just API key. Attribution helps us pinpoint and correct expensive workloads.
Here's something important to know: cutting down on tokens does not guarantee a decrease in the overall cost. A model that costs less, however, requires multiple retries and calls to the model, making it potentially more expensive per task compared to a more expensive model that finishes its task in a single run.
Cheapest Model Isn't Always the Cheapest AI Workload
Price per token and cost per completed task are two different numbers. A model with a lower price per token can still cost more per task if it uses more tokens, has longer execution times, requires more retries, or has a lower first-pass success rate. OpenAI suggests that users compare models by demonstration rather than price per million tokens in order to avoid misleading comparisons.
Because of this, it is more useful to evaluate cost per completed task. This is total AI spend divided by the number of tasks completed. Using this framework, a support bot that costs $0.015 per ticket and resolves 60% of tickets would be cheaper than a bot that costs $0.010 per ticket and resolves 40% of tickets but requires more intervention and handling.
Rate cards tell you what a model charges per token. Your own production data tells you what it costs to complete the task.
How to Reduce the Infrastructure Cost Behind AI Workloads

Everything above addresses one layer of AI spend: what you pay your provider for tokens. Optimizing tokens will not help with the other part of these costs, the infrastructure costs for the AI workloads.
The costs of using LLMs/APIs include token input, output, cached, and model usage fees. Infrastructure costs of AI include GPUs and other hardware, Kubernetes, storage, and other services used in the AI pipeline.
A team can carry out all the strategies in this article, cut input, cap output, cache aggressively, route intelligently, and still be running underutilized compute, oversized Kubernetes nodes, or on-demand capacity. Token optimization reduces the cost of using AI models. Infrastructure optimization reduces the cost of running the systems around them. These are different problems with different solutions:
Optimize compute utilization: Examine the resources supporting your AI stack and look for idling or underutilized resources before deciding to increase capacity.
Match infrastructure to demand: Align resources with demand by considering actual workload patterns instead of overprovisioning resources for peak demand.
Optimize cloud commitments: Consider your options for predictable workloads. Reserved Instances, Savings Plans, and Committed Use Discounts can provide deep discounts for a specific term and commitment compared to the standard per-use pricing for a given service.
How Pump helps
This is the layer Pump is built to handle. Pump connects to AWS, GCP, and Azure, uses read-only access to analyze your cloud spend, and can automate savings through commitment management, infrastructure recommendations, and other optimization strategies.
Pump is free for customers and earns revenue through its relationships with cloud providers rather than charging customers a separate optimization fee.
For teams running AI workloads in the cloud, that makes infrastructure optimization a complement to token optimization, not a replacement for it.
Conclusion
The price per million tokens is more of a placeholder. Production AI workloads will consume many more tokens than the initial user request. There are system prompts, conversation history, RAG context, agent loops, and retries, to name a few. Additionally, the least expensive model on the rate card may not be the most efficient way to complete a task.
There are two main efforts to reduce the overall AI spend. The first is optimizing token economics by caching, model routing, and context management, and the second is optimizing the cloud infrastructure where the workloads are run. Use the strategies mentioned above to reduce token costs. For the infrastructure side, connect your cloud accounts to Pump to understand your cloud costs and savings opportunities.
Frequently Asked Questions
What is the difference between input and output token costs?
Input tokens are what you send to the model, including prompts, instructions, and context. Output tokens are what the model generates. Providers usually charge more for output because it requires sequential token generation.
Are cached tokens cheaper?
Yes. Cached input tokens are typically much cheaper than standard input when previously processed context can be reused. The exact discount and caching rules vary by provider.
Why are LLM output tokens more expensive?
Output is generated sequentially, with each token depending on the previous ones. Input can largely be processed in parallel, so generating output generally requires more compute and is priced higher.
Similar Blog Posts
From Spreadsheet Nightmares to Cloud Cost Optimization
LLM Cost Optimization: How to Reduce AI Infrastructure Costs









