package ocaml-ai-sdk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e3437d6ebf48ec9f5d9a8afd62eaeece124023f02dbd87e4b291205fd309b72
sha512=605c10ed62c0cbc31a151b7031cc80a284d5c94231c1ef423ae7439572e3fadddab4a45f52eaeeef83973a8e324839b9fda03f9082deef1b6781353f63975510
doc/ocaml-ai-sdk.ai_provider_openrouter/Ai_provider_openrouter/Cache_control_options/index.html
Module Ai_provider_openrouter.Cache_control_optionsSource
Per-content-part cache control via Provider_options for OpenRouter.
Mirrors Ai_provider_anthropic.Cache_control_options but uses Openrouter_cache_control.t. Resolution follows upstream getCacheControl() in src/chat/convert-to-openrouter-chat-messages.ts: look up the OpenRouter key first, then fall back to the Anthropic Cache_control_options.Cache key for compatibility with prompts written against the Anthropic-native provider.
Supported placement today:
- System message: pass via
Generate_text.system_provider_options/Stream_text.system_provider_options. - User text and file parts: attach to each
Prompt.user_part'sprovider_options. - Assistant text, file, reasoning, and tool_call parts: attach to each
Prompt.assistant_part'sprovider_options. - Tool results: attach to each
Prompt.tool_result'sprovider_options.
Not yet supported: Message-level provider_options on Prompt.User, Prompt.Assistant, and Prompt.Tool variants. Upstream resolves messagePO ?? partPO, but our Prompt.message type does not carry provider_options on those constructors — only on Prompt.System. Set the cache marker on the specific part (typically the last text part for a multi-part user message) or on the tool_result instead. Tracked in docs/plans/2026-03-26-v3-roadmap.md under "Message-level provider_options on User / Assistant / Tool prompts".
type Ai_provider.Provider_options.key += | Cache : Cache_control.t Ai_provider.Provider_options.key(*GADT key for per-part cache control on OpenRouter requests.
*)
val with_cache_control :
?cache_control:Cache_control.t ->
Ai_provider.Provider_options.t ->
Ai_provider.Provider_options.tAdd cache control to provider options. No-op if cache_control is None.
Extract cache control from provider options.
Resolution order (mirrors upstream openrouter.cacheControl ?? openrouter.cache_control ?? anthropic.cacheControl ?? anthropic.cache_control):
Openrouter_cache_control_options.Cache(this module's key)Ai_provider_anthropic.Cache_control_options.Cache(record rebuilt at the boundary)