package ocaml-ai-sdk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=cb3b82428abcda76c02ec92f8103a4db28edf3f42795794a37135e9a3c40af96
sha512=11be8889ee25bee67b2be00553c42a4692bc73e5ce23985e8bb87f8a07e9d8f556b5a63b219fe5fe30366c8b0d4edae494afa80ccfbfcb112f1fa1e458de55bf
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)