aifree.dev

Why is the second call cheaper?

Prompt caching · Builder · 5 min · tokens, llm · after Tokens

Prompt caching reuses the work on a prompt’s opening when the next call starts with exactly the same text. Cached tokens are billed far below normal input, but only for long enough prefixes, sent again within minutes.

Before you start: could you explain this to a friend?

1 = not at all · 5 = easily

  1. 1 Guess first

    You ask two questions about the same long document. Why can the second call cost less?
  2. 2 Look

    The same start, billed once

    1 / 5
    call 1
    system prompt + 20-page doc · 10,000 tokensQ: summary? · 50
    call 2
    system prompt + 20-page doc · 10,000 tokensQ: risks? · 50

    Two calls about the same document. Only the question at the end differs.

    token counts illustrative

    Two calls about the same long document. Only the question at the end changes.

    Only an identical opening is cached: written once at a small premium, then read at about a tenth of the price, if the next call comes soon and the prefix is long enough.

  3. The prefix is the opening of your prompt: tools, system prompt, documents. Providers keep the work on a long prefix for a few minutes. If the next call starts with exactly the same text, those tokens are billed as cached input. So put what never changes first, and the question last.

  4. 4 You are the model

    You are the cache. For each call, decide: hit or miss?

    call 1 of 5 · Claude Sonnet 4.6, default cache

    Same 10,000-token document, new question at the end, 2 minutes later

    Anthropic prompt-caching docs (checked 2026-10-21)

    You are the cache: hit or miss?
  5. 5 Check

    Where should a timestamp or a user’s name go in your prompt?
  6. 6 Say it back

  7. 7 Mission · 5 min

    With a free Gemini API key, send Gemini 3.8 Flash the same long document (over 4,096 tokens) with two different questions at the end, a minute apart. Read usage.total_cached_tokens in both responses. Then move one sentence from the end to the very top and try again.

Three quick ones

Drawn at random from this lesson's pool; different next time.

Done?

Now: could you explain this to a friend?

1 = not at all · 5 = easily

Answer the three quick ones first.

Sources

  • https://platform.claude.com/docs/en/build-with-claude/prompt-caching (checked 2026-10-21; no update date): 5-minute cache writes 1.25×, 1-hour 2×, reads 0.1× base input (0.05× on Opus/Sonnet 5.5, 0.025× on Fable/Mythos 5.1); default lifetime 5 minutes, refreshed on use; minimum 1,024 tokens on Claude Sonnet 4.6 (512–4,096 by model); “Cache hits require 100% identical prompt segments”; usage cache_read_input_tokens / cache_creation_input_tokens
  • https://developers.openai.com/api/docs/guides/prompt-caching (checked 2026-10-21; no update date): on by default; minimum 1,024 tokens on GPT-5.6 and later; reads 0.1×, writes 1.25× (30-minute default); usage.input_tokens_details.cached_tokens
  • https://ai.google.dev/gemini-api/docs/caching (updated 2026-10-13, checked 2026-10-21): implicit caching on by default for Gemini 2.5 and newer; minimum 4,096 tokens on Gemini 3.8 Flash; hits in usage.total_cached_tokens; the page does not say whether the free tier gets cache hits
  • https://ai.google.dev/gemini-api/docs/pricing (updated 2026-10-19, checked 2026-10-21): Gemini 3.8 Flash input free of charge on the free tier
  • Token counts (10,000 + 50) and the 1-unit base price in the picture are illustrative; the bills are arithmetic on Anthropic’s multipliers

Published Oct 21, 2026 · updated Oct 21, 2026

Embed this

Paste this into a blog post or course page: the lesson's main picture in an iframe, with a link back to the full lesson.

<iframe src="https://aifree.dev/embed/explain/prompt-caching" width="100%" height="620" style="border:0;max-width:720px" title="Why is the second call cheaper? (aifree.dev Explain)" loading="lazy"></iframe>
<p><a href="https://aifree.dev/explain/prompt-caching">Why is the second call cheaper? Interactive lesson on aifree.dev</a></p>

Never miss new offers and news

New tools, credits, and AI news are added regularly. Pick how you want to hear about them.

Telegram channel
Join @aifree_dev and get new free AI offers and news right in your Telegram feed.
Browser notifications
Turn on push notifications and get an alert on this device whenever something new is posted. No account needed.
Email newsletter
A weekly digest of new, changed and expiring free AI offers. Double opt-in, one-click unsubscribe.

Unsubscribe anytime. Privacy

Frequently asked questions

What is aifree.dev?

aifree.dev helps everyone access AI through a curated directory of free AI tools, API credits, free tiers, and startup programs for coding, image, voice, video, and students - verified regularly.

How are offers presented?

Each offer includes its access details, free models when available, and expiration information when provided. Limited-time deals stay visible so they are easy to compare.

Do education and startup programs need verification?

Yes. Providers usually ask students to verify their status with a school email, student ID, or a program like the GitHub Student Pack, and ask startups to verify company details such as age, funding, or website. Check each offer’s claim page for the exact requirements.

What kinds of free AI offers are listed?

Free tiers and free trials from AI providers, free API credits, startup and student programs, and free tools for coding, image generation, voice, and video.

How can I suggest a tool or report a broken link?

Use the submit form: paste the offer page URL and a short note. A person checks every submission before anything is listed. Broken links and changed terms go through the same form.

+

Know a good one?

Tell us about an AI tool worth knowing. Found a broken link? We want to hear that too.

Submit an offer