Prompt caching
Make long sessions cheaper and faster.
Coding agents resend the same long conversation on every turn. With prompt caching, the repeated part is billed at the cheaper cache read price and the answer starts faster.
Is it automatic?
For most users, yes:
- Claude Code — fully automatic; it sends its own session id.
- Other tools — AivoKey recognises a conversation by how it starts, which works in most cases. Sending a session id (below) makes it reliable.
Sending a session id
Use the same value for every request of one conversation, and a new value for a new conversation. Either set a header:
x-opencode-session: my-session-id
or put session_id in the JSON body.
Good to know
- Caching is best-effort: if the route a conversation uses becomes unavailable, your request is served elsewhere instead of failing — it just misses the cache once.
- You can see your cache hit rate in Console → Usage.
- Models with the cache badge on Models support it.