Skip to main content

RetryOptions

Retry-policy options accepted by withRetry. The same policy is used by every namespace client method; the exported helper is useful when you need that behavior on a call that isn’t wrapped yet (e.g., a direct call to adaline.deploymentsApi.* or adaline.logsApi.*).

Definition

interface RetryOptions {
  retries?: number;
  minTimeout?: number;
  maxTimeout?: number;
  randomize?: boolean;
  maxRetryTime?: number;
  factor?: number;
}

Fields

FieldTypeDefaultDescription
retriesnumber10Maximum number of retry attempts on 5xx responses.
minTimeoutnumber1000Minimum delay between attempts (ms).
maxTimeoutnumber10000Maximum delay between attempts (ms).
factornumber2Exponential backoff factor. Each retry waits factor × the previous delay.
randomizebooleantrueIf true, adds jitter to each delay.
maxRetryTimenumber20000Hard ceiling on total time spent retrying (ms). The retry loop gives up once this is exceeded.

Defaults

The exported DEFAULT_RETRY_OPTIONS constant is what every namespace client uses:
const DEFAULT_RETRY_OPTIONS: RetryOptions = {
  retries: 10,
  minTimeout: 1000,
  maxTimeout: 10000,
  randomize: true,
  maxRetryTime: 20000,
  factor: 2,
};

Behavior

  • 5xx responses — retried with exponential backoff and jitter.
  • 4xx responses — aborted immediately via AbortError; no retries.
  • Network errors — retried like 5xx.

Usage

import { Adaline, withRetry } from '@adaline/client';

const adaline = new Adaline();

// Short-circuit retries for a latency-sensitive path
const deployment = await withRetry(
  () => adaline.deploymentsApi.getDeployment('prompt_abc123', 'deploy_xyz789'),
  { retries: 2, maxRetryTime: 2000 },
);

See Also