Skip to main content
Available on all Portkey plans.
  • Up to 5 retry attempts
  • Trigger on specific error codes
  • Exponential backoff to prevent overload
  • Optionally respect providerโ€™s Retry-After headers

Examples

The @provider-slug/model-name format automatically routes to the correct provider. Set up providers in Model Catalog.

Retry on Specific Error Codes

Default retry codes: [429, 500, 502, 503, 504, 529] Override with on_status_codes:
When on_status_codes is set, retries trigger only on those codesโ€”not the defaults.

Respect Provider Retry Headers

Enable use_retry_after_headers to use the providerโ€™s retry-after-ms, x-ms-retry-after-ms, or retry-after headers instead of exponential backoff.
When use_retry_after_headers is set to true and the provider includes Retry-After or Retry-After-ms headers in their response, Portkey will use these values to determine the wait time before the next retry attempt, overriding the exponential backoff strategy. If the provider doesnโ€™t include these headers in the response, Portkey will fall back to the standard exponential backoff strategy. The cumulative retry wait time for a single request is capped at 60 seconds. For example, if the first retry has a wait time of 20 seconds, and the second retry response includes a Retry-After value of 50 seconds, the request will fail since the total wait time (20+50=70) exceeds the 60-second cap. Similarly, if any single Retry-After value exceeds 60 seconds, the request will fail immediately.

Exponential Backoff

Retry Attempt Header

Check x-portkey-retry-attempt-count in responses:
Retry attempts arenโ€™t logged individually. Response times are summed in a single log entry.

Portkey is now PRISMA AIRS AI Gateway. See it in action.

Contact Us
Last modified on August 3, 2026