package ocaml-ai-sdk

  1. Overview
  2. Docs
OCaml AI SDK - Provider abstraction for AI models

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ocaml-ai-sdk-0.6.1.tbz
sha256=cb3b82428abcda76c02ec92f8103a4db28edf3f42795794a37135e9a3c40af96
sha512=11be8889ee25bee67b2be00553c42a4692bc73e5ce23985e8bb87f8a07e9d8f556b5a63b219fe5fe30366c8b0d4edae494afa80ccfbfcb112f1fa1e458de55bf

doc/ocaml-ai-sdk.ai_provider/Ai_provider/Provider_error/index.html

Module Ai_provider.Provider_errorSource

Errors from provider API calls.

Sourcetype timeout_phase =
  1. | Request_headers
    (*

    Not retryable: the server may already be processing the request.

    *)
  2. | Stream_idle
    (*

    Retryable: the connection has gone silent and is treated as dead.

    *)
Sourcetype error_kind =
  1. | Api_error of {
    1. status : int;
    2. body : string;
    }
  2. | Network_error of {
    1. message : string;
    }
  3. | Deserialization_error of {
    1. message : string;
    2. raw : string;
    }
  4. | Timeout of {
    1. phase : timeout_phase;
    2. elapsed_s : float;
    3. limit_s : float;
    }
Sourcetype t = {
  1. provider : string;
  2. kind : error_kind;
  3. is_retryable : bool;
  4. retry_after_s : float option;
}
Sourceexception Provider_error of t
Sourceval make_api_error : provider:string -> status:int -> body:string -> ?is_retryable:bool -> ?retry_after_s:float -> unit -> t

Construct an API error.

When is_retryable is omitted, defaults to the upstream status-code heuristic: 408, 409, 429, or any 5xx are retryable. Providers may override this when they can parse the error type from the response body.

Sourceval make_timeout : provider:string -> phase:timeout_phase -> elapsed_s:float -> limit_s:float -> t

Construct a timeout error. is_retryable is derived from phase: Request_headers is not retryable (server may already be processing the request; retry risks double-billing); Stream_idle is retryable (stream is dead, safe to start over).

Sourceval to_string : t -> string