Skip to content
Dashboard

Customize timeouts for faster automatic failover on Vercel AI Gateway

/* In this example, the BYOK credentials for GPT 5.4 would timeout
after 15 seconds and fallback to system credentials. */
const result = streamText({
model: 'openai/gpt-5.4',
prompt,
providerOptions: {
gateway: {
providerTimeouts: {
byok: { openai: 15000 }, // 15 seconds
},
},
},
});

/* This example tries Anthropic first with a 10-second timeout, falls back to Bedrock
with 15 seconds, then Vertex with the default gateway timeout. */
const result = streamText({
model: 'anthropic/claude-sonnet-4.6',
prompt,
providerOptions: {
gateway: {
order: ['anthropic', 'bedrock', 'vertex'],
providerTimeouts: {
byok: {
anthropic: 10000,
bedrock: 15000,
},
},
},
},
});

This example tries Anthropic first with a 10-second timeout, falls back to Bedrock with 15 seconds, then Vertex with the default gateway timeout.

Ready to deploy?