Cost control

LLM API pricing: tokens, caching, and cost control

The rate card is only the beginning. Learn how to estimate the cost of a useful result—and which engineering choices actually reduce it.

By 01gate Editorial Team · Updated October 20, 2026 · 6 min read

Most LLM APIs bill input and output tokens separately, commonly per million tokens. Input is everything you send: system instructions, chat history, documents, tool descriptions, and the current user message. Output is every generated token. Because output rates are often higher, unbounded answers can be a larger cost driver than long prompts.

A simple cost estimate

request cost = (input tokens × input rate) + (cached input tokens × cache rate) + (output tokens × output rate)

Use one unit for each term. If rates are quoted per million tokens, divide token counts by one million first. Multiply the average request cost by expected volume. This reveals which part of the workflow is expensive instead of leaving you to guess from a monthly bill.

Why cached input matters

Some models price reused prompt prefixes at a lower cached-input rate. This matters when a system prompt, policy, long document, or tool schema is sent repeatedly. Caching is not an excuse to send unlimited context: a smaller relevant prompt is still easier to follow and often faster. But stable prefix design can improve high-volume economics.

Four costs teams miss

A practical control loop

  1. Log tokens, cache hits, model, latency, and a task-success signal.
  2. Set output limits and use structured responses where appropriate.
  3. Summarize or retrieve history instead of replaying every message.
  4. Route routine work economically and escalate exceptions.
  5. Review cost per successful task weekly, not just total spend.
Do not optimize cost alone. Compare cost per accepted result. A more expensive model can be cheaper when it removes retries, human correction, or downstream failures.

Continue reading