package ocaml-ai-sdk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=44e7f6ebef6da2828ec2844dd5b38c8f37284c08e54a29e06f6a8822df6f8e10
sha512=ce31d0868abf28bcaef7b24a0ab09b37dcfc94db3de96b38ff36a03800ae59a19e8009a35314f93191b3c8f178c40f8569630d4389f56ddc2f2cc94fb7bffc3c
doc/ocaml-ai-sdk.ai_core/Ai_core/Retry/index.html
Module Ai_core.RetrySource
Retry with exponential backoff for provider calls.
Wraps a thunk and retries on retryable Provider_error exceptions and transient network errors (Unix.Unix_error with ECONNRESET, ETIMEDOUT, etc.). Other errors are re-raised immediately. Matches upstream AI SDK retry behavior.
val with_retries :
?max_retries:int ->
?initial_delay_ms:int ->
?backoff_factor:int ->
?max_retry_delay_ms:int ->
?sleep:(float -> unit Lwt.t) ->
?random:(unit -> float) ->
(unit -> 'a Lwt.t) ->
'a Lwt.tRetry a thunk with exponential backoff.
A server retry_after_s hint on the error, when present and reasonable, REPLACES the exponential backoff for that attempt (it may shorten as well as lengthen the delay — it is not a lower bound). Following upstream, a hint of ms milliseconds is reasonable iff ms >= 0 and either ms < 60000 or ms is below the un-jittered exponential delay for this attempt. Rejected hints fall back to the jittered exponential backoff. Jitter never applies to an accepted hint.