Module Chatoyant_nativeSource

Eio 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.

Sourcemodule Clock : sig ... end

Environment lookup backed by Sys.getenv_opt.

Sourcemodule Http : sig ... end
Sourcemodule Websocket : sig ... end
Sourcemodule Error : sig ... end
Sourcemodule Provider : sig ... end
Sourcemodule Chat : sig ... end
Sourcetype client = Chat.t

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.

Sourceval 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.. > -> client

OpenAI client for one-shot shortcuts and chat forks.

Sourceval 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.. > -> client

Anthropic client for one-shot shortcuts and chat forks.

Sourceval 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.. > -> client

xAI client for one-shot shortcuts and chat forks.

Sourceval 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.. > -> client

OpenRouter client for one-shot shortcuts and chat forks.

Sourceval 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 -> client

Local OpenAI-compatible client for one-shot shortcuts and chat forks.

Sourceval 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) result

One-shot generation returning full metadata. The supplied client is forked before messages are appended.

Sourceval 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) result

One-shot text generation.

Sourceval 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) result

One-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.

Sourcemodule Generate : sig ... end