# Cache promptu (wspólny początek zapytań)

EN: **Prompt (prefix) caching** · id `promptcaching`

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Produkt i wdrażanie AI](https://aiatlasgraph.com/t/product.md) › [Koszt, jakość i opóźnienie](https://aiatlasgraph.com/t/economics.md) › [Cache w aplikacjach LLM](https://aiatlasgraph.com/t/llmcaching.md) › Cache promptu (wspólny początek zapytań)

## Description

- PL: Ponowne użycie już przetworzonego stałego początku promptu — instrukcji systemowych, definicji narzędzi, długich dokumentów — za ułamek ceny i z krótszym czasem do pierwszego tokenu.
- EN: Reusing an already processed fixed prompt prefix — system instructions, tool definitions, long documents — at a fraction of the price and with a shorter time to first token.

## In one sentence

- PL: To ponowne używanie obliczeń dla identycznego początku kolejnych zapytań do modelu.
- EN: This reuses calculations for the identical beginning of successive model requests.

## Problem it solves

- PL: Długie instrukcje i dokumenty są przetwarzane wielokrotnie, choć zmienia się dopiero pytanie na końcu.
- EN: Long instructions and documents are processed repeatedly even when only the final question changes.

## What it does

- PL: Zachowuje obliczenia wspólnego początku, a przy kolejnym zapytaniu wykorzystuje je i przetwarza nową część oraz generuje nową odpowiedź.
- EN: It stores calculations for the shared beginning, then reuses them while processing the new part and generating a new answer.

## Everyday example

- PL: Zadajesz różne pytania o ten sam długi regulamin; model może wykorzystać zapisane obliczenia jego treści przy każdym kolejnym pytaniu.
- EN: You ask different questions about the same long policy; the model can reuse stored calculations of that text for each subsequent question.

## This concerns you if you…

- PL: twoje zapytania mają długi identyczny początek
- PL: często pracujesz z tym samym dokumentem lub instrukcjami
- EN: have requests sharing a long identical beginning
- EN: often work with the same document or instructions

## Keywords

cached input tokens · shared prompt prefix · cache write tokens · cache read tokens · cache TTL · prefill reuse

## How it works

- PL: Silnik zachowuje wynik przetwarzania wspólnego prefiksu, zwykle stan kluczy i wartości uwagi. Kolejne zapytanie ponownie wykorzystuje zgodny fragment i oblicza dalszą część kontekstu, zamiast przeliczać cały początek.
- EN: An engine retains processing results for a shared prefix, typically attention key–value state. Subsequent requests reuse the matching portion and compute the remaining context instead of reprocessing the entire opening.

## Limits

- PL: Zgodność zależy od tokenów, pozycji i wersji modelu. Zmiana początku ogranicza trafienia; progi, okres ważności i rozliczenie zależą od silnika lub dostawcy, a odpowiedź nadal jest generowana.
- EN: Matching depends on tokens, positions and model versions. Prefix changes reduce hits; thresholds, expiration and billing depend on engines or providers, while answers still require generation.

## Key terms

- PL: **prefiks promptu**: Początkowy fragment kontekstu współdzielony przez kolejne zapytania.
- PL: **prefill**: Przetwarzanie wejściowych tokenów przed rozpoczęciem generowania odpowiedzi.
- EN: **prompt prefix**: An initial context segment shared across successive requests.
- EN: **prefill**: Processing input tokens before response generation starts.

## Know first

- [Tokenizacja tekstu (BPE, WordPiece, SentencePiece) (Text tokenisation (BPE, WordPiece, SentencePiece))](https://aiatlasgraph.com/t/tokenization.md)
- [Mechanizm self-attention (zapytania, klucze, wartości) (Self-attention (queries, keys, values))](https://aiatlasgraph.com/t/selfattention.md)

## Examples

- PL: stałe elementy na początku promptu · czas życia cache (TTL) · odczyt z cache taniej niż zwykłe tokeny
- EN: stable content at the start of the prompt · cache time-to-live · cache reads cheaper than regular tokens

## Related topics

Untyped, symmetric "see also" links.

- [Zarządzanie KV cache (KV cache management)](https://aiatlasgraph.com/t/kvcache.md)

## Sources

- [Prompt caching — Claude API documentation](<https://platform.claude.com/docs/en/build-with-claude/prompt-caching>) `anthropic-prompt-caching` · by Anthropic

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/promptcaching · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
