How to implement prompt caching using Claude models?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2025 01:00 AM
Hi,
I am trying to use prompt caching future using claude "databricks-claude-sonnet-4" databricks endpoint (wrapped in a ChatDatabricks instance). Using langchain, I set
SystemMessage(
content=[
{
"text": cached_doc_prompt,
"type": "text",
"cache_control": {"type": "ephemeral"},
}
]
),for the part of the message I want to cache.
I get this error:
Response text: {"error_code":"BAD_REQUEST","message":"BAD_REQUEST: Databricks does not support prompt cache for the first-party Anthropic model."}How can prompt caching be achieved in databricks?
thanks for your help!