Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Input vs. Output Token Pricing

Hello! Welcome to the first lesson in our module on LLM Token Economics and Billing Systems.

In the previous module, we engineered an LLM inference service, focusing intensely on performance. We concluded by evaluating the fundamental trade-off between latency and throughput, and we saw how this tension is rooted in the different computational profiles of the prefill (input processing) and decode (output generation) stages.

This lesson builds directly on that foundation. We'll move from the technical cost drivers to the business layer built on top: the pricing models you'll encounter as a user of LLM APIs. Our learning outcome is to describe typical input vs. output token pricing models and the rationale for their cost difference. By the end of this lesson, you'll understand not just what you're paying for, but why it's priced the way it is—a crucial perspective when designing cost-effective applications.

1. The Currency of LLMs: Tokens and Usage-Based Pricing

Before we can discuss cost, we must understand the unit of currency: the token. Large language models don't process raw text; they work with a numerical representation of it. Tokens are these fundamental units, which can be whole words or, more commonly, parts of words.

To get a clear picture of what tokens are and how they form the basis for API billing, let's watch a short video.

LLM Pricing Explained (OpenAI API Pricing)

The video 'LLM Pricing Explained' from Tommy Eberle provides a great introduction to the core concepts of API billing, tokens, and the distinction between input and output.

Please watch from the beginning until 00:05:46. As you watch, focus on: The analogy of API billing to a utility meter (like an electric bill). The clear distinction between input tokens (what you send to the model) and output tokens (what the model generates). How text is broken down into tokens, and that it's not a simple one-to-one mapping with words.

As the video explained, LLM providers like Anthropic and OpenAI primarily use a "pay-as-you-go" model for their APIs. You are billed based on the number of tokens you process.

This pricing is almost always broken down into two distinct categories:

  • Input Tokens: The tokens that make up your prompt (the instructions and context you provide).
  • Output Tokens: The tokens that the model generates in its response.

Take a look at this pricing table, which shows the rates for several popular models. Notice the consistent pattern.

LLM Token Pricing Comparison Table
A comparison of pricing for various LLMs as of early 2025. Note that for every model, the price per million output tokens is significantly higher than the price for input tokens. For example, Claude 3.5 Sonnet charges \$3.00 for input vs. \$15.00 for output—a 5x difference.

The key observation is that output tokens are consistently more expensive than input tokens, often by a factor of 3 to 5, and sometimes even more. The rest of this lesson is dedicated to understanding why.

2. The Rationale: Parallel Prefill vs. Sequential Decode

This price difference is not arbitrary; it's a direct reflection of the underlying computational cost and resource utilization on the GPU, a topic we touched upon in our last module.

Let's revisit the two phases of LLM inference:

  1. Prefill (Processing Input): When you send a prompt, the model processes all of its tokens in a single, highly parallel forward pass. This operation is typically compute-bound. It's like a large, efficient matrix multiplication that can fully leverage the GPU's parallel cores. The entire prompt is processed at once.

  2. Decode (Generating Output): Generating the response is an autoregressive process. The model generates one token, appends it to the sequence, and then uses that new sequence to predict the next token. This must be done sequentially, one token at a time. Each step requires a new, separate forward pass. This operation is almost always memory-bound.

The following article provides an excellent technical explanation for why this difference leads to a cost disparity. Given your background in system design, you will find the discussion of GPU architecture and memory bandwidth particularly relevant.

Why do LLM input tokens cost less than output tokens? - Peter Chng

The article 'Why do LLM input tokens cost less than output tokens?' by Peter Chng breaks down the technical reasons for the pricing gap, connecting it directly to GPU hardware constraints.

Please read the introduction, the section on memory cost, and the summary section that begins with 'Going back to our question of input vs. output tokens cost:'. Start from the beginning and read until the paragraph just before the H100 specs ('So why the dollar cost difference? ... we haven’t looked at memory cost:'). Then, read the two bullet points that directly compare the generation of output tokens to the processing of input tokens. Finally, read the section starting from 'Going back to our question of input vs. output tokens cost:' to the end of that section ('...so inefficient in this way.'). \nFocus on how the number of forward passes impacts memory usage.

Let's crystallize the key points from that reading:

  • Input processing is efficient: A prompt with tokens is processed in one forward pass. The model weights are loaded from the GPU's slow global memory (HBM) to its fast on-chip memory (SRAM) once, and then a large amount of computation is performed. This amortizes the high cost of memory transfer.

  • Output generation is inefficient: Generating a response of tokens requires separate forward passes. For each token, the massive model weights must be read from global memory again. This results in a low ratio of computation to memory access, leaving the powerful compute cores idle while waiting for data. The process is memory-bound.

In essence, generating output tokens occupies the expensive GPU hardware for a longer duration and uses it less efficiently than processing the input prompt. The higher price you pay for output tokens is a direct charge for this increased and less efficient resource consumption.

This is analogous to resource utilization in your work on Rudi at AWS. A task that can be heavily parallelized and batched will have a much lower cost-per-unit-of-work than a task that requires sequential processing and repeatedly ties up a critical resource while doing minimal work in each step.

3. A Practical Example

Let's consider a common task: summarizing a document.

  • Prompt: "Please summarize the following 1000-word article in under 100 words: [article text...]"
  • Input Tokens: A 1000-word article is roughly 1,300 tokens.
  • Output Tokens: A 100-word summary is roughly 130 tokens.

Using the rates for Anthropic's Claude 3.5 Sonnet ($3/M input, $15/M output):

  • Input Cost:
  • Output Cost:

Even though there are 10 times more input tokens, the cost is only about double the output cost. This clearly illustrates the premium paid for the memory-intensive work of generating the response.

Conclusion

In this lesson, we demystified the pricing models of modern LLM APIs. You now have a solid, first-principles understanding of why these systems are priced the way they are.

Key Takeaways:

  • LLM API usage is priced per token, with costs split between input and output.
  • Output tokens are consistently more expensive than input tokens, often by a factor of 3-5x.
  • This cost difference is not arbitrary but is rooted in the underlying computer architecture.
  • Input processing (prefill) is a parallel, compute-bound operation that is highly efficient.
  • Output generation (decode) is a sequential, memory-bound operation that uses GPU resources less efficiently, tying them up for longer to produce each token. The higher price reflects this inefficiency and increased resource cost.

Next Lesson Preview

Now that you understand the why behind token pricing, our next step is to apply this knowledge. In the next lesson, we will learn how to calculate the cost for various request patterns, such as summarization vs. few-shot prompting. We'll explore how the structure of your prompt directly impacts the final cost of an API call.

Can't find a good explanation? Sign up and we'll make it for you

Sign up