-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Description
Anthropic recently enabled auto caching: https://platform.claude.com/docs/en/build-with-claude/prompt-caching#automatic-caching
- Instead of explicit cache breakpoints (at message level), you can now enable auto caching
- For this, we need to add a cache_control parameter
"cache_control": {"type": "ephemeral"},at the top_level of the request to the Anthropic API:
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-4-6",
"max_tokens": 1024,
"cache_control": {"type": "ephemeral"},
"system": "You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
"messages": [
{
"role": "user",
"content": "Analyze the major themes in Pride and Prejudice."
}
]
}'
I tried the following, but it doesn't seem to work:
return new ToolLoopAgent({
model,
instructions,
tools,
stopWhen: stepCountIs(maxSteps),
providerOptions: {
openrouter: {
cacheControl: { type: 'ephemeral' },
},
},
});
Is this something already supported, but should we configure this differently? Or is this something that needs to be implemented? In many usecases, this can save you significant costs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels