| Name | Type | Description |
|---|---|---|
type | Literal['ephemeral'] | Default: 'ephemeral'The type of cache to use. For ChatBedrock, only
|
ttl | Literal['5m', '1h'] | Default: '5m'The time to live for the cache, only |
min_messages_to_cache | int | Default: 0 |
unsupported_model_behavior | Literal['ignore', 'warn', 'raise'] | Default: 'warn' |
Prompt Caching Middleware for ChatBedrock and ChatBedrockConverse.
Optimizes API usage by caching conversation prefixes for supported models on AWS Bedrock. Supports Anthropic Claude and Amazon Nova models.
For ChatBedrock (InvokeModel API), adds cache_control to the last
message's content block. For ChatBedrockConverse (Converse API), appends
cachePoint blocks to the system prompt and last message.
Requires both 'langchain' and 'langchain-aws' packages to be installed.
Learn more about prompt caching at:
Anthropic <https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching>AWS Bedrock <https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html>The minimum number of messages until the cache is used, default is 0.
The behavior to take when an
unsupported model is used. "ignore" will ignore the
unsupported model and continue without caching. "warn"
will warn the user and continue without caching. "raise"
will raise an error and stop the agent.