Skip to main content

Documentation Index

Fetch the complete documentation index at: https://gomodel-docs-providers-restructure.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

GoModel wraps every upstream provider call with two resilience layers:
  1. Retry with exponential backoff — repeats a failed request against the same provider with growing delays.
  2. Circuit breaker — short-circuits calls to a provider that has been failing repeatedly, then probes once the timeout elapses.
Both layers apply per provider. They do not switch to a different model or provider on failure. For cross-model fallback, see Failover.

Defaults

The defaults are tuned to be safe for most deployments. Override only what you need.
SettingDefaultNotes
max_retries3Maximum retry attempts per request
initial_backoff1sFirst retry wait
max_backoff30sUpper cap on retry wait
backoff_factor2.0Exponential multiplier between retries
jitter_factor0.1Random jitter as a fraction of the backoff
failure_threshold5Consecutive failures before the circuit opens
success_threshold2Consecutive successes to close it again
timeout30sHow long the circuit stays open before probing

Environment Variables

These set the global defaults that apply to every provider unless overridden in YAML.

Retry

VariableTypeDefaultDescription
RETRY_MAX_RETRIESint3Maximum retry attempts per request
RETRY_INITIAL_BACKOFFduration1sFirst retry wait (e.g. 500ms, 2s)
RETRY_MAX_BACKOFFduration30sUpper cap on retry wait
RETRY_BACKOFF_FACTORfloat2.0Exponential multiplier between retries
RETRY_JITTER_FACTORfloat0.1Random jitter as a fraction of the backoff

Circuit Breaker

VariableTypeDefaultDescription
CIRCUIT_BREAKER_FAILURE_THRESHOLDint5Consecutive failures before opening
CIRCUIT_BREAKER_SUCCESS_THRESHOLDint2Consecutive successes to close again
CIRCUIT_BREAKER_TIMEOUTduration30sHow long the circuit stays open before probing

YAML

The same fields are available under the global resilience: block, and can be overridden per provider:
resilience:
  retry:
    max_retries: 2
    initial_backoff: 500ms
    max_backoff: 10s
    backoff_factor: 1.5
    jitter_factor: 0.05
  circuit_breaker:
    failure_threshold: 3
    success_threshold: 1
    timeout: 15s

providers:
  anthropic:
    type: anthropic
    api_key: ${ANTHROPIC_API_KEY}
    resilience:
      retry:
        max_retries: 5 # Anthropic supports long requests — allow more retries

  ollama:
    type: ollama
    base_url: ${OLLAMA_BASE_URL:-http://localhost:11434/v1}
    resilience:
      circuit_breaker:
        failure_threshold: 10 # local service — tolerate more transient failures
        timeout: 5s
Only fields explicitly listed under a provider’s resilience: block are overridden. Everything else inherits from the global section, which in turn inherits from the built-in defaults.
Per-provider tuning must come from YAML. Environment variables set global defaults only — RETRY_MAX_RETRIES cannot target a single provider. See config.yaml gotchas.

Worked example

Given the YAML above, the effective per-provider settings are:
Providermax_retriesfailure_thresholdcb timeout
openai2 (global)3 (global)15s (global)
anthropic5 (override)3 (global)15s (global)
ollama2 (global)10 (override)5s (override)
anthropic and ollama inherit every field they did not explicitly override.

Failover vs. Resilience

The retry and circuit breaker layers stay on a single provider. If you also want GoModel to try a different model or provider when the primary keeps failing, configure manual fallback rules. See Failover.