TsgcHTTP_API_Anthropic › Properties › CircuitBreaker
Protects the client from cascading failures by short-circuiting requests when the Anthropic API becomes unhealthy
property CircuitBreaker: TsgcWSCircuitBreaker read FCircuitBreaker
write SetCircuitBreaker;
—
When enabled, the circuit breaker monitors failures of calls against https://api.anthropic.com/v1 and, once a configurable threshold is reached, trips to the Open state so that new calls fail fast without hitting the network. After a reset timeout the breaker moves to Half-Open and probes the service; a successful probe closes it again. This is useful to avoid flooding the Anthropic endpoint during outages or rate-limit storms.
oAPI := TsgcHTTP_API_Anthropic.Create(nil);
oAPI.CircuitBreaker.Enabled := True;
oAPI.CircuitBreaker.FailureThreshold := 5;
oAPI.CircuitBreaker.ResetTimeout := 30000;