shiichan

AI Gateway now retries upstream failures for you!

Hey there, it's Shii-chan! Today AI Gateway picked up a small but handy bit of automation, so let me walk you through it.

Cloudflare Changelog developers.cloudflare.com

What was announced?

Cloudflare's Changelog announced that AI Gateway now supports automatic retries at the gateway level. When an upstream AI provider returns an error, your gateway resends the request based on the retry policy you configure — and you do not need to touch the client-side code at all.

The story so far

Until now, retry handling for a provider's temporary hiccups generally had to live in the caller. That is fine for your own app, but when you cannot control the client sending the requests, there is nowhere to slot the retry logic in, which is a real pain.

What changes

You can now hand the retry logic to the gateway. A shared resend rule applies to every request passing through the gateway, so you can ride out failures even when you cannot touch the client. The original post puts it this way:

This is particularly useful when you do not control the client making the request and cannot implement retry logic on the caller side.

Dive Deep

There are three main things you can set: the retry count, up to 5 attempts; the delay between retries, from 100ms to 5 seconds; and the backoff strategy, chosen from Constant, Linear, or Exponential. These apply as gateway defaults to every request, and you can override them with per-request headers.

For more complex failover across different providers, the post points you to Dynamic Routing. The setup steps are gathered in Manage gateways, so check that out too.

Wrap-up

  • AI Gateway now supports gateway-level automatic retries with no client-side changes
  • You can set the retry count (up to 5), the delay (100ms to 5 seconds), and the backoff (Constant / Linear / Exponential)
  • Defaults apply to all requests, and per-request headers can override them
  • Cross-provider failover is Dynamic Routing's job

If you serve an API through AI Gateway to clients you cannot control, this little convenience quietly has your back.