Skip to main content
Configure multiple provider keys in an access key configuration routing rule. The gateway tries keys in order when one hits a rate limit, runs out of quota, or fails authentication.

How failover works

When a routing rule step lists multiple provider keys:
  1. The gateway tries the first key.
  2. On a rate limit (429), or an auth failure (401 or 403) because the provider rejected the key, it tries the next key.
  3. When no keys are left, the gateway falls back to paying with credits if the rule has an ngrok step after this one. Otherwise it moves to the next model you listed, or returns the last error.
Server errors (5xx), timeouts, and connection failures don’t try the next key. Another key for the same provider would likely fail the same way, so the gateway moves straight to the next model you listed. To fail over on those errors, add fallback models. Failover is configured per provider in the access key configuration—not in your application code.

Via dashboard

  1. Add multiple provider keys for the same provider.
  2. Edit an access key configuration.
  3. Add or edit a routing rule for the provider.
  4. Attach multiple keys to the Bring your own API key step in the order you want them tried.

Via the AI Gateway API

See the Access Key Configurations API reference. Assign the configuration to your access key. Your app sends only the access key:

Next steps