aifree.dev

Vì sao lần gọi thứ hai lại rẻ hơn?

Prompt caching (bộ nhớ đệm prompt) · Thực hành · 5 phút · tokens, llm · học sau Token

Prompt caching dùng lại phần việc đã làm trên đoạn mở đầu của prompt khi lần gọi sau bắt đầu bằng đúng văn bản đó. Token trong cache tính giá thấp hơn nhiều so với input thường, nhưng chỉ khi đoạn đầu đủ dài và được gửi lại trong vài phút.

Trước khi bắt đầu: bạn giải thích được chuyện này cho bạn bè không?

1 = hoàn toàn không · 5 = dễ dàng

  1. 1 Đoán trước

    Bạn hỏi hai câu về cùng một tài liệu dài. Vì sao lần gọi thứ hai có thể rẻ hơn?
  2. 2 Xem

    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.

    Chỉ đoạn mở đầu y hệt mới được cache: ghi một lần với giá nhỉnh hơn, rồi đọc lại với giá khoảng một phần mười, nếu lần gọi sau đến sớm và prefix đủ dài.

  3. Prefix là đoạn mở đầu của prompt: tool, system prompt, tài liệu. Nhà cung cấp giữ phần việc trên một prefix dài trong vài phút. Nếu lần gọi sau bắt đầu bằng đúng văn bản đó, các token ấy được tính là cached input (input trong cache). Vậy hãy đặt phần không bao giờ đổi lên đầu, câu hỏi xuống cuối.

  4. 4 Bạn là model

    Bạn là cache. Với mỗi lần gọi, hãy quyết định: hit (trúng) hay miss (trượt)?

    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 Kiểm tra

    Nên đặt mốc thời gian hay tên người dùng ở đâu trong prompt?
  6. 6 Nói lại bằng lời bạn

  7. 7 Nhiệm vụ · 5 phút

    Với một API key Gemini miễn phí, gửi cho Gemini 3.8 Flash cùng một tài liệu dài (hơn 4.096 token) kèm hai câu hỏi khác nhau ở cuối, cách nhau một phút. Đọc usage.total_cached_tokens trong cả hai response. Rồi chuyển một câu từ cuối lên đầu tài liệu và thử lại.

Ba câu nhanh

Rút ngẫu nhiên từ bộ câu hỏi của bài; lần sau sẽ khác.

Xong chưa?

Còn bây giờ: bạn giải thích được cho bạn bè chưa?

1 = hoàn toàn không · 5 = dễ dàng

Trả lời ba câu nhanh trước đã.

Nguồn

  • 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

Đăng Oct 21, 2026 · cập nhật Oct 21, 2026

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