Files
spring-ai/prompt-caching/output/07-openai-automatic-caching.txt

21 lines
1.2 KiB
Plaintext

# OpenAI through Spring AI 2.1.0: no breakpoints to place, where a message boundary falls, and a cached count in Usage
A. Same system prompt, different question (simulated rule: longest shared message-boundary prefix of at least 1,024 tokens)
request carried prompt_cache_key=support-assistant-v1 keys sent: [messages, model, prompt_cache_key]
call 1: getPromptTokens=6410 getCacheReadInputTokens=0 getCacheWriteInputTokens=null
call 2: getPromptTokens=6408 getCacheReadInputTokens=6080 getCacheWriteInputTokens=null
as a price-sheet bill: plain=328 read=6080 write=0
B. A clock inside the one big system message (the simulation caches whole messages, the GPT-5.6-and-later rule)
call 2: 0 of 6097 prompt tokens cached
C. The clock moved to its own message after the stable one, so a message boundary falls where the text starts to change
call 2: 6080 of 6097 prompt tokens cached
D. A prompt under 1,024 tokens (simulated minimum): no error, no caching
call 2: 0 of 635 prompt tokens cached
E. Options that exist in Spring AI 2.1.0, and one that has to travel through extraBody
keys on the wire: [messages, model, prompt_cache_key, prompt_cache_retention]
prompt_cache_retention=24h