Most LLM gateways promise fallback, but the implementation details determine whether your app survives a provider outage. In this head-to-head on n4n vs Portkey fallback, we dissect how each handles degraded upstreams, what it costs, and the ergonomic trade-offs you’ll hit at 3am.
Capabilities
Automatic fallback is not a checkbox; it’s a policy. n4n routes requests to a single OpenAI-compatible endpoint that fronts 240+ models and triggers automatic fallback when a provider is rate-limited or degraded. You send a standard chat completion request, and the gateway decides whether to retry on an alternate provider behind the scenes. It also honors client routing directives and forwards provider cache-control hints, so you keep control over where tokens go without writing failover logic.
Portkey takes a declarative approach. You specify an ordered list of providers and models in the request body or in a stored virtual key config. The gateway walks that list on error, timeout, or specific rate-limit status codes. This gives fine-grained control: you can fall back from GPT-4o to Claude, then to a self-hosted vLLM instance, with distinct timeouts per hop.
{
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": "Summarize this"}],
"fallback": [
{"provider": "anthropic", "model": "claude-3-5-sonnet"},
{"provider": "groq", "model": "llama-3.1-70b"}
]
}
The trade-off is obvious: n4n’s fallback is opaque but zero-config, while Portkey’s is explicit and composable. If you need to guarantee a specific secondary model for compliance, Portkey wins. If you want to ship tonight, the n4n vs Portkey fallback complexity leans toward n4n.
What “degraded” means
Portkey treats non-200 responses, timeouts, and HTTP 429/5xx as triggers. n4n applies similar heuristics internally but does not expose the chain. For teams debugging tail latency, Portkey’s transparency is valuable; for teams that just want requests to succeed, n4n’s silence is a feature.
Cache and routing control
n4n forwards cache-control headers to the upstream provider, letting you exploit provider-side prompt caching without leaving the OpenAI shape. Portkey mirrors this via its own header scheme and adds response caching at the gateway layer. Both let you pin a provider via model prefix (openai/..., anthropic/...), but only Portkey lets you express weighted load balancing alongside fallback.
Price and cost model
Neither gateway charges for the fallback attempt itself; you pay for tokens that flow. n4n.ai meters per-token usage on the routed request, so a failed attempt that doesn’t return tokens costs nothing. Portkey’s model layers a platform subscription on top of provider spend, with a free tier capped at request volume and paid tiers adding SSO, audit logs, and higher limits.
The hidden cost is engineering time. Writing and maintaining fallback arrays, virtual keys, and retry budgets in Portkey is real work. n4n’s automatic fallback shifts that burden to the gateway. For a seed-stage team, the n4n vs Portkey fallback cost equation is less about API margins and more about ops headcount. If you already have a platform team, Portkey’s subscription is negligible against the control it buys.
Latency and throughput
Adding a proxy hop costs 10–30ms typically. Fallback adds tail latency only when the first provider fails. Portkey’s sequential fallback can stack: if OpenAI times out at 5s and Claude takes 2s, your p99 jumps to 7s plus proxy overhead. You can cap per-hop timeout in the config, but the linear chain remains.
n4n’s internal fallback is concurrent or pre-emptive depending on health checks; because it’s automatic, you can’t tune per-hop timeout, but you avoid the worst-case linear stack. Throughput is bounded by the gateway’s upstream connections. Both scale horizontally; Portkey documents autoscaling on enterprise plans, n4n’s metering implies similar elasticity.
# n4n: standard client, fallback invisible
from openai import OpenAI
client = OpenAI(base_url="https://api.n4n.ai/v1", api_key="sk-...")
resp = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Go"}]
)
# On provider degradation, the gateway retries upstream; your code unchanged.
Ergonomics
Drop-in compatibility matters. n4n speaks the OpenAI API shape, so any existing SDK, LangChain wrapper, or curl works unchanged. You switch the base URL and you have fallback. Portkey also offers an OpenAI-compatible route, but to use fallback you must inject the fallback field or use its SDK. That means touching every call site or centralizing via a wrapper.
# Portkey requires gateway-specific body shaping
curl https://api.portkey.ai/v1/chat/completions \
-H "x-portkey-api-key: $PK" \
-d '{"model":"openai/gpt-4o","fallback":[{"provider":"anthropic"}],"messages":[]}'
For local development, n4n’s “just point and go” is less friction. Portkey’s dashboard gives you request traces, which speeds root-causing. The n4n vs Portkey fallback ergonomics split is: invisible vs observable.
SDK footprint
Portkey ships a Python and TS SDK that wraps the fallback config in typed objects. n4n needs no SDK—the official OpenAI package is sufficient. If you enforce strict dependency trees, n4n’s zero-dependency-gateway approach is easier to clear with security review.
Ecosystem
Portkey ships integrations: LangChain, LlamaIndex, Helm charts, and a weighty observability UI. It is built to be the control plane for your AI traffic. n4n, by virtue of OpenAI compatibility, inherits the entire OpenAI toolchain without native plugins. You get metrics via its metering API rather than a built-in dashboard.
If you already live in Datadog and want custom spans, Portkey’s export is friendlier. If you want to avoid vendor SDK lock-in, n4n’s stance is pragmatic: one endpoint, standard client. Both support OpenTelemetry traces, but Portkey’s console reduces the plumbing.
Limits
Portkey free tier enforces request-per-minute caps and restricts advanced routing to paid plans. Complex fallback graphs can hit config size limits. n4n’s automatic fallback only triggers on provider degradation; it will not execute arbitrary multi-model workflows you define. You cannot say “try A, then B, then C with a different prompt” without external code.
Both gateways inherit provider rate limits. Neither magically gives you more GPT-4o quota. Portkey’s virtual keys can aggregate multiple provider accounts to raise ceilings; n4n’s single endpoint abstracts that but does not expose key pooling.
Comparison table
| Dimension | n4n | Portkey |
|---|---|---|
| Fallback model | Automatic on degradation, opaque | Explicit ordered list, configurable |
| Cost | Per-token metering, no platform fee disclosed | Subscription + provider spend, free tier |
| Latency control | Gateway-managed, no per-hop tuning | Per-hop timeout, retry budget |
| Ergonomics | OpenAI drop-in, zero config | OpenAI-compatible + fallback field/SDK |
| Ecosystem | OpenAI toolchain, metering API | Native LangChain/observability UI |
| Limits | No custom chains, 240+ models | Config caps, tier-based throttling |
Which to choose
Choose n4n if you run a lean team shipping a product that must not crash when OpenAI hiccups. Point your OpenAI client at the endpoint, and the n4n vs Portkey fallback decision is made for you. You trade visibility for simplicity and per-token billing with no surprise platform fee.
Choose Portkey if you operate multi-region, multi-provider infrastructure with compliance demands. You need to declare that PII never leaves a specific model, or you want to load-balance across three providers with weighted splits. The configuration overhead pays off in auditability and a rich trace UI.
Choose neither if you have the engineering muscle to run your own Envoy-based router; both are thin proxies over provider APIs. For most startups, the automatic fallback in n4n covers 90% of outages. For platform teams building an internal AI gateway, Portkey’s explicit routing is the better foundation. The n4n vs Portkey fallback debate is really about who writes the failover code: you or the gateway.