Skip to content

Commit 4fa31fc

Browse files
committed
docs(ai-chat): note prompt caching needs AI SDK v6+
1 parent 5171e99 commit 4fa31fc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

docs/ai-chat/prompt-caching.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ A request renders as `tools` → `system` → `messages`. There are three prefix
3030

3131
The system prompt (your `chat.prompt` text plus any skills preamble) is usually the largest stable block, so it's the first thing to cache. `chat.toStreamTextOptions()` returns `system` as a plain string by default; opt into caching and it returns a structured system message carrying the cache breakpoint instead.
3232

33+
<Note>
34+
System-prompt caching needs AI SDK v6 or later, where the `system` parameter accepts a structured message. On AI SDK v5 `system` is a plain string, so these options won't apply a breakpoint to the system block — cache the conversation via `prepareMessages` instead.
35+
</Note>
36+
3337
Three ways to opt in, depending on where you'd rather express it.
3438

3539
**`cacheControl` at the `streamText` call site** — the Anthropic-flavored one-liner:

0 commit comments

Comments
 (0)