Prompt Caching / Message Role Metadata
Recall that an LLM request usually looks like this, where it sometimes has metadata in each message
. In this case, Anthropic has a cache_control
key.
This is nearly the same as this BAML code, minus the cache_control
metadata:
Let’s add the cache-control
metadata to each of our messges in BAML now.
There’s just 2 steps:
We have the “allowed_role_metadata” so that if you swap to other LLM clients, we don’t accidentally forward the wrong metadata to the new provider API.
Remember to check the “raw curl” checkbox in the VSCode Playground to see the exact request being sent!