@openai-prod
and @anthropic-prod
.pip install portkey-ai
.@openai-prod
provider. The failure will be induced directly in our request config by referencing a model name that does not exist.
404 Not Found
error from the provider and automatically retry with the valid fallback provider.
FAILED
: The first request to @openai-prod
, which failed with a 404 Not Found
status because the model name was invalid.SUCCESS
: The automatic fallback request to @anthropic-prod
.429 Too Many Requests
error. This recipe shows how to configure a fallback that triggers only on this specific error.
@openai-prod
) and apply a strict Rate Limit: 1 Request per Minute.
on_status_codes: [429]
to ensure the fallback only triggers for rate limit errors.
FAILED
attempt to @openai-prod
with a 429
status, followed by the SUCCESS
call to @anthropic-prod
.
446
status code. You can use this to trigger a fallback, perhaps to a different model better suited for the filtered content.
Deny the request if guardrail fails
flag.
guardrail ID
for next step
fallback-on-guardrail-fail
.
input_guardrails
block is nested inside the first target:
446
error and the fallback.
FAILED
: The first attempt to @openai-prod
, blocked by the word_count
guardrail with a 446
status.SUCCESS
: The automatic fallback to @anthropic-prod
, which processed the input.on_status_codes
to control precisely which errors trigger a fallback. This prevents unnecessary fallbacks on transient issues.