TsgcHTTP_API_OpenAI › Properties › CircuitBreaker
Retry and rate-limit handling policy used when OpenAI endpoints fail transiently
property CircuitBreaker: TsgcWSCircuitBreaker read FCircuitBreaker
write SetCircuitBreaker;
—
Provides a TsgcWSCircuitBreaker policy that wraps every OpenAI REST call with configurable retries, exponential backoff and rate-limit awareness. When the server replies with 429 Too Many Requests or a 5xx status, the circuit breaker pauses the client using the Retry-After header and re-issues the request up to the configured maximum attempts. Once the failure threshold is exceeded the breaker opens and subsequent calls fail fast until the cooldown window elapses. Enable it to make long-running AI workflows resilient against transient OpenAI outages.
oAPI.CircuitBreaker.Enabled := True;
oAPI.CircuitBreaker.MaxRetries := 5;
oAPI.CircuitBreaker.RetryDelay := 2000;
oAPI.CircuitBreaker.ExponentialBackoff := True;