Skip to main content

Module retry

Module retry 

Source
Expand description

Exponential backoff retry wrapper for LLMClient. Exponential backoff retry wrapper for LLMClient.

Wraps any LLMClient implementation with configurable retry logic. Retries on rate-limit (429) and server errors (5xx) with exponential backoff and jitter to avoid thundering-herd behavior.

Streaming is not retried — the caller receives the raw stream from the inner client. Streaming retry is complex and left for a future version.

§Example

use llm_kernel::llm::{LLMClient, OpenAIClient, RetryClient, RetryConfig};
use std::time::Duration;

let client = OpenAIClient::from_key("gpt-4o", "sk-...")?;
let retry = RetryClient::new(client, RetryConfig {
    max_retries: 3,
    base_delay: Duration::from_secs(1),
});
let response = retry.complete(request).await?;

Structs§

RetryClient
An LLMClient wrapper that retries on transient errors.
RetryConfig
Configuration for retry behavior.