Specifically I would like to enable caching with RooCode using Claude models as it significantly reduces cost with the huge number of tokens used.
Bedrock supports prompt caching via cachePoint blocks, but the gateway currently only accepts string content for system and developer messages. The OpenAI SDK sends cache control hints as structured content:
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant.", "cache_control": {"type": "ephemeral"}}
]
}
This structured format is silently rejected or ignored.
Proposed solution
- Add a
CacheControl model and cache_control field on TextContent in the schema
- Change
SystemMessage.content and DeveloperMessage.content to accept str | list[TextContent]
- Handle list-format system/developer messages in
_parse_system_prompts — extract text and emit Bedrock cachePoint blocks when cache_control is set
- Emit
cachePoint in _parse_content_parts for user message content with cache markers
This allows clients using the OpenAI SDK's prompt caching pattern to have their cache hints translated to Bedrock's native cachePoint format.
Files: src/api/schema.py, src/api/models/bedrock.py
Specifically I would like to enable caching with RooCode using Claude models as it significantly reduces cost with the huge number of tokens used.
Bedrock supports prompt caching via
cachePointblocks, but the gateway currently only accepts string content for system and developer messages. The OpenAI SDK sends cache control hints as structured content:{ "role": "system", "content": [ {"type": "text", "text": "You are a helpful assistant.", "cache_control": {"type": "ephemeral"}} ] }This structured format is silently rejected or ignored.
Proposed solution
CacheControlmodel andcache_controlfield onTextContentin the schemaSystemMessage.contentandDeveloperMessage.contentto acceptstr | list[TextContent]_parse_system_prompts— extract text and emit BedrockcachePointblocks whencache_controlis setcachePointin_parse_content_partsfor user message content with cache markersThis allows clients using the OpenAI SDK's prompt caching pattern to have their cache hints translated to Bedrock's native
cachePointformat.Files:
src/api/schema.py,src/api/models/bedrock.py