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 for non-streaming calls. The whole call must finish within call_timeout.
  • Time to first token for streaming calls. See Timeout with streaming.
  • Every retry and fallback attempt. Each attempt gets its own call_timeout, except on the streaming Responses API, where the attempts share the request deadline.
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 the Evaluator’s timeout, or 60 seconds if it has none, and configurable up to 10 minutes. See Guardrail timeout.

Timeout error

When call_timeout fires, the gateway cancels the attempt and answers with HTTP 408:
408 is in the default retry codes and the default fallback codes, so the caller receives this error only after retries and fallbacks are exhausted.

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, chat completions and non-streaming calls: timeout × (1 + retry_count) × (1 + fallback_count)
  • Primary plus 2 fallbacks with a 15s timeout and the default 2 retries: 15s × 3 attempts × 3 models, up to 135s plus retry backoff delays.
  • The whole request is also capped by an internal request deadline: 12 minutes for requests that are not streaming or that run an Agent, and 30 minutes for other streaming model requests. With timeout omitted, the 12-minute default already equals the non-streaming deadline.

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

With stream: true, call_timeout bounds the wait for the first token, not the total duration of the stream. The timer stops when the first chunk arrives, so a stream that keeps producing tokens can run longer than call_timeout. After the first token, the gateway cancels the stream only when the provider stays silent for longer than the stream idle timeout, which is 12 minutes. If the timeout fires before the first token, /v3/router/chat/completions returns HTTP 408 with the timeout_error body from Timeout error. On /v3/router/responses, a stream that is already open ends with a response.failed event whose error.code is timeout_error. On the streaming Responses API, attempts share the overall request deadline, so a retry’s first-token budget is capped at the remaining request budget divided by the attempts left.

Circuit breaker pattern

Limitations

  • Fixed timeout: call_timeout does not adapt to prompt length or model.
  • Fallback multiplication: Every fallback attempt gets the same call_timeout, so worst-case latency multiplies by the number of attempts.
  • Provider variations: Different providers have different baseline response times.
  • Streaming: call_timeout bounds only the first token; the stream idle timeout bounds the rest.

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.