Skip to content

Comments

feat(anthropic): Add support for automatic caching#917

Open
satoved wants to merge 3 commits intoprism-php:mainfrom
satoved:feature/anthropic-automatic-caching
Open

feat(anthropic): Add support for automatic caching#917
satoved wants to merge 3 commits intoprism-php:mainfrom
satoved:feature/anthropic-automatic-caching

Conversation

@satoved
Copy link
Contributor

@satoved satoved commented Feb 20, 2026

Problem

Prism's Anthropic provider only supports explicit cache breakpoints — where you manually place cache_control on individual content blocks (system messages, user messages, tools). There's no way to use Anthropic's automatic caching, which accepts a single top-level cache_control field on the request body and automatically applies caching to the last cacheable block — the simplest approach for multi-turn conversations.

Solution

Pass cache_control as a provider option (withProviderOptions(['cache_control' => ['type' => 'ephemeral']])) and forward it as a top-level field in the Anthropic API payload for both Text and handlers. This lets users opt into automatic caching with a single line, without changing how explicit breakpoints work.

Breaking Changes

None.

@satoved satoved changed the title [Anthropic] Add support for automatic caching feat(anthropic): Add support for automatic caching Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant