Module Chatoyant_native.HttpSource

Sourcetype multipart_part = {
  1. name : string;
  2. filename : string option;
  3. content_type : string option;
  4. body : string;
}
Sourcetype body =
  1. | Empty
  2. | Text of string
  3. | Json of Chatoyant_runtime.Json.t
  4. | Multipart of multipart_part list
Sourcetype request = {
  1. method_ : string;
  2. url : string;
  3. headers : (string * string) list;
  4. body : body;
  5. timeout_ms : int option;
}
Sourcetype response = {
  1. status : int;
  2. headers : (string * string) list;
  3. body : string;
}
Sourcetype error =
  1. | Timeout of int
  2. | Network of string
  3. | Invalid_response of string
Sourceval error_to_string : error -> string

Human-readable HTTP error rendering for app/tool handlers.

Sourcemodule type EFFECT = Chatoyant_runtime.Effect.HTTP with type multipart_part = multipart_part and type body = body and type request = request and type response = response and type error = error

HTTP effect module with types tied to Chatoyant.Http.

Sourcetype client_certificate = {
  1. certificate_pem : string;
  2. private_key_pem : string;
  3. authenticator : X509.Authenticator.t option;
}

PEM-encoded client certificate chain and private key for mTLS provider endpoints. When authenticator is omitted, system trust roots are used for server verification.

Sourcetype https =
  1. | System
    (*

    Use system trust roots through ca-certs and verify HTTPS hosts.

    *)
  2. | Authenticator of X509.Authenticator.t
    (*

    Build a TLS client from a caller-supplied X.509 authenticator.

    *)
  3. | Mutual_tls of client_certificate
    (*

    Use system/server authentication plus a PEM client certificate.

    *)
  4. | Tls_config of Tls.Config.client
    (*

    Use an already constructed TLS client config.

    *)
  5. | Disabled
    (*

    Disable HTTPS. Plain HTTP URLs still work; HTTPS URLs fail fast.

    *)
Sourceval default_max_response_size : int

Default response body limit, currently 100 MiB.

Sourceval tls_config : ?authenticator:X509.Authenticator.t -> unit -> (Tls.Config.client, string) result

Build the TLS client config used by System and Authenticator.

Sourceval mtls_config : ?authenticator:X509.Authenticator.t -> certificate_pem:string -> private_key_pem:string -> unit -> (Tls.Config.client, string) result

Build a TLS client config with a PEM certificate chain/private key for mTLS endpoints such as xAI enterprise deployments.

Sourceval make : ?https:https -> ?max_response_size:int -> net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> unit -> (module EFFECT)

make ~net ~clock () creates a Chatoyant HTTP effect backed by cohttp-eio.

Multipart bodies are encoded at this boundary, JSON bodies receive a default content-type: application/json header when absent, and timeout_ms is enforced with Eio.Time.with_timeout.

Sourceval send : ?https:https -> ?max_response_size:int -> net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> request -> (response, error) result

One-shot HTTP request helper for Eio-native app/tool code. For provider clients that issue many requests, prefer make and reuse the returned effect module.

Sourceval get : ?https:https -> ?max_response_size:int -> ?headers:(string * string) list -> ?timeout_ms:int -> net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> string -> (response, error) result

Convenience GET helper.

Sourceval get_json : ?https:https -> ?max_response_size:int -> ?headers:(string * string) list -> ?timeout_ms:int -> net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> string -> (Chatoyant_runtime.Json.t, error) result

Convenience GET helper that parses a successful response body as JSON.

Sourceval post_json : ?https:https -> ?max_response_size:int -> ?headers:(string * string) list -> ?timeout_ms:int -> net:_ Eio.Net.t -> clock:_ Eio.Time.clock -> string -> Chatoyant_runtime.Json.t -> (response, error) result

Convenience JSON POST helper.