Skip to main content
Use Cases
  • Preventing slow models from blocking user-facing requests indefinitely.
  • Setting different limits for interactive (short) vs. batch (long) workloads.
  • Triggering fallback logic when a provider exceeds an acceptable wait time.
  • Enforcing response-time SLAs on latency-sensitive features.

Quick Start

Set maximum request duration to prevent hanging requests.

Configuration

Timeout applies to:
  • Model generation time.
  • Network transfer time.
  • All fallback attempts (each gets same timeout).
call_timeout bounds the model call only. It does not bound Guardrails or Evaluators: each Guardrail reference on the request has its own timeout, defaulting to 60 seconds and configurable up to 10 minutes. See Guardrail timeout.

Code examples

Error Handling

Best Practices

Timeout selection:
  • Set based on user experience requirements.
  • Consider model complexity and prompt length.
  • Factor in network latency (add 2-5s buffer).
  • Test with realistic prompts and data.
Environment-specific timeouts:
Progressive timeouts:

Fallback Integration

Timeouts work seamlessly with fallbacks:
Total possible time: timeout × (1 + fallback_count)
  • Primary + 2 fallbacks with 15s timeout = up to 45s total.

Troubleshooting

Frequent timeouts
  • Increase timeout value.
  • Use faster models (gpt-5.4-mini vs gpt-5.6-sol).
  • Reduce prompt complexity/length.
  • Check provider status for slowdowns.
User experience issues
  • Set timeout based on user expectations.
  • Show loading states for longer operations.
  • Implement progressive enhancement.
  • Consider async processing for long tasks.
Performance optimization

Advanced Patterns

Dynamic timeout adjustment:
Timeout with streaming:
Circuit breaker pattern:

Limitations

  • Fixed timeout: Same timeout applies to all requests.
  • Model-call scope: call_timeout bounds the model call only. Guardrails and Evaluators use their own per-guardrail timeout.
  • Fallback multiplication: Each fallback gets the same timeout duration.
  • Provider variations: Different providers have different baseline response times.
  • Streaming considerations: Streaming responses may need longer timeouts.

Monitoring

Key metrics to track:
  • Timeout rate: % of requests that timeout.
  • Average response time: Baseline performance.
  • 95th percentile: For setting optimal timeouts.
  • Timeout impact: User experience degradation.
  • Model performance: Response times by model.