Customize timeouts for faster automatic failover on Vercel AI Gateway
By Steven Van ·
The beta feature works only with BYOK credentials for now and lets developers set failover windows from one second up to about 13 minutes.
Vercel's AI Gateway now supports per-provider timeouts, so a slow response can trigger failover faster than waiting for a provider's own default. If a provider doesn't start streaming within the configured window, AI Gateway aborts the request and falls back to the next available provider.
Timeouts are set in milliseconds through providerTimeouts in providerOptions.gateway, and can be paired with order to control both the sequence of providers tried and how long each one gets before failover. Configured values must fall between 1,000ms and 789,000ms (about 13 minutes). For streaming requests, the timeout clears as soon as the first chunk arrives; for non-streaming requests it runs until the full response comes back. Response metadata now includes providerTimeout and configuredTimeoutMs fields, so a request's provider attempts show which one timed out and when.
The feature is in beta and works only with BYOK (Bring Your Own Key) credentials, with support for system provider timeouts coming later. Some providers don't support stream cancellation, so a timed-out request may still be billed depending on the provider.
Read the provider timeouts documentation for setup details.