For AI engineering
Prompt caching simulator
Reorder the parts of a request and watch cache hits and cost change over a conversation.
Order of the request, top to bottom
- 1Current date and timechanges every turn, 50 tokens
- 2System promptsame every turn, 2.0k tokens
- 3Tool definitionssame every turn, 6.0k tokens
- 4Reference documentssame every turn, 20.0k tokens
- 5Conversation so fargrows every turn, +800/turn tokens
- 6The user's new messagechanges every turn, 200 tokens
Cache hit rate
0%
Input cost, this chat
$0.745
Without caching
$0.745
- Turn 10 / 28.3k
- Turn 20 / 29.1k
- Turn 30 / 29.9k
- Turn 40 / 30.6k
- Turn 50 / 31.4k
- Turn 60 / 32.3k
- Turn 70 / 33.0k
- Turn 80 / 33.9k
read from cache (about 10% of the price) processed in full
“Current date and time” sits above system prompt, tool definitions, reference documents, so 28.0k stable tokens are re-processed on every turn. Move the parts that never change to the top.
Simplified: real APIs also have cache breakpoints, a minimum cacheable size, expiry after a few minutes of no use, and a small premium for writing to the cache.