Chatoyant_nativeSourceEio runtime integration for native Chatoyant consumers.
This library keeps the provider implementations runtime-neutral while making the native path feel natural in Eio applications. Build the HTTP and clock effects from an Eio_main.run environment, then pass the resulting modules to the existing provider/core functors or use the provider constructors below.
Environment lookup backed by Sys.getenv_opt.
Reusable native Chatoyant client.
Top-level shortcut calls fork this value before generating, so repeated gen_text and gen_data calls do not mutate the client's message history. Use Chat directly when you want an accumulating conversation.
val openai :
?https:Http.https ->
?max_response_size:int ->
?base_url:string ->
?timeout_ms:int ->
?model:string ->
?defaults:Chatoyant_core.Options.t ->
?api_key:string ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
< net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > ->
clientOpenAI client for one-shot shortcuts and chat forks.
val anthropic :
?https:Http.https ->
?max_response_size:int ->
?base_url:string ->
?timeout_ms:int ->
?beta_headers:string list ->
?model:string ->
?defaults:Chatoyant_core.Options.t ->
?api_key:string ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
< net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > ->
clientAnthropic client for one-shot shortcuts and chat forks.
val xai :
?https:Http.https ->
?max_response_size:int ->
?base_url:string ->
?timeout_ms:int ->
?model:string ->
?defaults:Chatoyant_core.Options.t ->
?api_key:string ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
< net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > ->
clientxAI client for one-shot shortcuts and chat forks.
val openrouter :
?https:Http.https ->
?max_response_size:int ->
?timeout_ms:int ->
?http_referer:string ->
?title:string ->
?headers:(string * string) list ->
?model:string ->
?defaults:Chatoyant_core.Options.t ->
?api_key:string ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
< net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > ->
clientOpenRouter client for one-shot shortcuts and chat forks.
val local :
?https:Http.https ->
?max_response_size:int ->
?api_key:string ->
?timeout_ms:int ->
?headers:(string * string) list ->
?model:string ->
?defaults:Chatoyant_core.Options.t ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
< net : _ Eio.Net.t ; clock : _ Eio.Time.clock.. > ->
base_url:string ->
clientLocal OpenAI-compatible client for one-shot shortcuts and chat forks.
val gen_result :
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
?options:Chatoyant_core.Options.t ->
?timeout_ms:int ->
?temperature:float ->
?max_tokens:int ->
?extra:Chatoyant_runtime.Json.t ->
client ->
string ->
(Chatoyant_core.Result.generation, Chatoyant_provider.Provider.error) resultOne-shot generation returning full metadata. The supplied client is forked before messages are appended.
val gen_text :
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
?options:Chatoyant_core.Options.t ->
?timeout_ms:int ->
?temperature:float ->
?max_tokens:int ->
?extra:Chatoyant_runtime.Json.t ->
client ->
string ->
(string, Chatoyant_provider.Provider.error) resultOne-shot text generation.
val gen_data :
?name:string ->
?description:string ->
?strict:bool ->
codec:'a Chatoyant_schema.Codec.t ->
?system:string ->
?tools:Chatoyant_core.Tool.t list ->
?options:Chatoyant_core.Options.t ->
?timeout_ms:int ->
?temperature:float ->
?max_tokens:int ->
?extra:Chatoyant_runtime.Json.t ->
client ->
string ->
('a, Chatoyant_provider.Provider.error) resultOne-shot typed JSON generation.
Prefer [%chatoyant.gen_data: your_type] with [@@deriving chatoyant] so the codec and schema stay invisible at the call site. OpenAI uses Responses structured output, OpenAI-compatible providers use response_format, and Anthropic receives a schema instruction plus local validation.