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.2.tbz
sha256=637f60398f673dfb2e661f6ed7da169b823a870d27b48e729d5b9200e46a52b2
sha512=5aec259473395025edb6689b544e57e821cfbef9352987f95eb2182034979ce898040e06e60a9d89a40a187b77fb5b1b7183c7ec4264da9d9a834864860a5fed

doc/ocaml-ai-sdk.ai_provider_openrouter/Ai_provider_openrouter/Openrouter_error/index.html

Module Ai_provider_openrouter.Openrouter_errorSource

OpenRouter API error handling.

Sourceval of_response : status:int -> body:string -> Ai_provider.Provider_error.t

Parse an HTTP error response into a provider error. Extracts the most specific readable message from OpenRouter's JSON error envelope (upstream provider name, raw upstream error, and error_type when available). The HTTP status is authoritative for retryability.

Sourceval of_response_with_retry_after : ?retry_after_ms:string option -> status:int -> body:string -> retry_after:string option -> unit -> Ai_provider.Provider_error.t

As of_response, parsing and preserving raw rate-limit hint headers. retry_after_ms (milliseconds) takes precedence over retry_after (seconds); see Ai_provider.Retry_after.parse.

Sourceval of_error_json : ?status:int -> ?retry_after_s:float -> Yojson.Basic.t -> Ai_provider.Provider_error.t

Build a Provider_error from an OpenRouter error object. Pass status on the HTTP error path so retryability keys off the real gateway status; omit it for 200-embedded, choice-level, and streaming errors, where the status is derived from error.code (default 200).