Models → Pricing → Docs → Blog → Changelog → Contact → Status →
Get started freeLog in

Prompt Caching and Token Costs: What Actually Saves

How prompt caching works at model providers, how to structure prompts for it, how FreeModel counts cached input tokens today, and what really cuts token use.

"Prompt caching" comes up in almost every conversation about LLM costs. It is a real technique at the model providers, and it is worth understanding. It is also easy to assume it saves money everywhere. This explainer covers how it works in general, how to structure prompts for it, and — plainly — how FreeModel counts cached input tokens today.

What prompt caching is

When a model reads a prompt, the provider does a lot of work on every input token before generating the first output token. Many requests start with the same text: a long system prompt, the same tool definitions, the same document, the same earlier turns of a chat.

Prompt caching lets the provider keep the processed form of a prefix for a short time. When the next request starts with exactly the same prefix, that part can be reused instead of processed again. Providers document two styles:

  • Automatic prefix caching. The provider caches long prefixes on its own; you just keep them identical.
  • Explicit breakpoints. In the Anthropic format you mark where the cacheable part ends with cache_control on a content block.

Cached prefixes typically live for minutes, not hours, and any change — even one character early in the prompt — means a miss from that point on. Providers that sell direct access often bill cache reads at a reduced rate; the exact terms are on each provider's own pricing page.

Structuring prompts for caching

These habits make a prefix cacheable, and they are good practice anyway:

  1. Stable content first. System prompt, tool definitions, reference documents — then the conversation — then the new question.
  2. No changing values at the top. A timestamp or request id in the first line of the system prompt makes every request unique.
  3. Same tools, same order. Serialise tool definitions deterministically.
  4. Append, do not rewrite. Editing an early message invalidates everything after it.

How FreeModel counts cached tokens

This is the part to read carefully. At the time of writing (November 2026), input tokens count toward your FreeModel plan in full, whether or not the model provider served them from a cache. There is no separate, lower rate for cached input.

Concretely:

  • When the provider reports a cache figure, the response passes it on for information — usage.prompt_tokens_details.cached_tokens on the OpenAI format, cache_read_input_tokens on the Anthropic format.
  • The prompt token total, which includes any cached part, is what counts, multiplied by the model's multiplier like every other token.
  • cache_control markers in Anthropic-format requests do not cause errors — Claude Code sends them and works normally — but they do not change what is counted.

So do not plan your FreeModel budget around cache discounts; current plan terms are on the pricing page.

A worked example

A support bot sends an 8,000-token fixed prefix (system prompt plus tool definitions) on every turn, on claude-sonnet-5 (3×). Over a 20-turn conversation:

Prefix tokens sentPlan tokens for the prefix
8,000-token prefix160,000480,000
Prefix cut to 3,000 tokens60,000180,000
3,000 tokens on claude-haiku-5.5 (1.5×)60,00090,000

On FreeModel, the first row costs the same whether the provider cached the prefix or not. The savings come from the second and third rows: sending fewer tokens and choosing the multiplier deliberately.

What actually lowers token use

TechniqueWhy it works here
Shorten the fixed promptIt is resent on every request
Trim and summarise historyHistory grows every turn (how)
Truncate tool resultsAgents resend them on every later step
Retrieve instead of stuffingSend the three passages that matter, not the whole manual
Pick the multiplier1.5× for routine work, 3× and up when the task needs it
Set max_tokens on purposeOutput tokens count too
Stop failing loopsFailed requests are not charged, but a stream you abort after output started counts

Measure before you optimise

Log the usage of every call for a day, and you will see where the tokens go:

import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["FREEMODEL_API_KEY"],
                base_url="https://freemodel.in/v1")

r = client.chat.completions.create(
    model="gpt-6-luna",
    messages=[{"role": "system", "content": SYSTEM_PROMPT},
              {"role": "user", "content": "Where is my order?"}],
)
u = r.usage
details = getattr(u, "prompt_tokens_details", None)
cached = getattr(details, "cached_tokens", 0) or 0
print(f"input {u.prompt_tokens:,} (provider cache: {cached:,}) "
      f"output {u.completion_tokens:,}")

If input dominates and most of it is the same prefix on every call, shortening that prefix is your biggest lever. If output dominates, look at max_tokens and at reasoning models that think at length (reasoning docs). The per-request numbers are also in the dashboard under usage.

Still worth structuring for caching?

Yes, for two reasons that do not depend on any discount. A stable, prefix-first prompt is easier to measure and to trim, because the fixed part is in one place. And it keeps your prompts ready for any provider that does discount cache hits, without a rewrite. Just do not count the discount in your FreeModel budget.

For a wider view of where token spend comes from, see understanding token pricing and estimating tokens before sending.

FAQ

Does FreeModel give a discount for cached input tokens?

Not at the time of writing. Input tokens count toward your plan whether or not the model provider served them from its cache.

Will cache_control in my Anthropic requests cause an error?

No. Claude Code sends these markers and works with FreeModel. They simply do not change what is counted.

Why does usage show cached_tokens if they are not discounted?

The figure is passed on for information when the provider reports it. The prompt token total, which includes those tokens, is what counts toward your plan.

What is the biggest saving on FreeModel then?

Sending fewer tokens: a shorter fixed prompt, trimmed history and truncated tool results, and choosing a model with a lower multiplier when the task allows.

Ready to build?

Grab a free API key — 1M tokens on 8 free models after a one-time Telegram verification, no card. Every model from $1.20.