Reliability & Streaming · Updated October 2026

AI gateway failover during streaming: the point where a backup cannot be invisible

Most AI gateway comparisons say 'automatic failover' without identifying when the failure happens. An upstream error before the first response byte is different from a broken stream after the application has already displayed text or received tool-call fragments. A buyer should demand explicit behavior for both situations, not an undefined promise of uninterrupted output.

Practical engineering guidance. Verify provider-specific capabilities, pricing, and support before deployment.

Key takeaways

  • Fallback before a response starts can be straightforward; replaying a partially delivered stream can duplicate content or actions.
  • Define a bounded retry and fallback budget and test model/tool compatibility.
  • Inspect actual provider attempts, streamed chunks and final cost accounting.
  • Treat vendor fallback documentation as a starting point, not evidence that mid-stream recovery is seamless.

Three failure moments that require different policies

First, a gateway may fail before it reaches the model provider: authentication, policy admission or network resolution. Second, the provider may reject the request before generating output, such as a rate-limit response or unavailable model. Third, a provider may begin streaming a response and then disconnect or stall. These are different states, even if a dashboard collapses them into one 'failed request' count.

Before the application has received any output, a gateway can often retry or select a compatible fallback within the caller's deadline. After output has been emitted, switching models can produce a new answer that contradicts or repeats the earlier text. In a tool-using workflow, the partial output might already have caused the client to prepare an action. A safe design makes this boundary explicit and exposes an error or resumable application state rather than pretending a second model continued the same generation.

  • Pre-admission failure: return an explicit authorization or policy error.
  • Pre-stream provider failure: retry or fallback only within approved policy.
  • Mid-stream interruption: preserve evidence of partial output and fail clearly.
  • Tool execution: use application-level idempotency and approval for external side effects.

What current gateway documentation actually promises

Portkey's fallback documentation describes a prioritized target list and configurable trigger status codes. It warns that alternate models may differ in capabilities, latency and cost, and that multiple invocations can occur. LiteLLM's architecture separates retries within a model group from fallbacks to another group; its key and team router settings can also vary routing policy. Neither statement alone should be interpreted as a universal guarantee that a partially delivered response can be stitched into a coherent stream.

Cloudflare's October 2026 dynamic-routing documentation describes versioned routes with model nodes, timeout/retry properties and fallback edges. Its JSON configuration says a model node's success output is reached when streaming successfully starts. That is an especially useful distinction to test: what happens if the stream starts successfully but later fails? Confirm actual behavior for your request format and gateway version. Cloudflare also documents that its dynamic routes accept the OpenAI chat-completions request shape, not every provider-native API.

  • Ask for a state diagram covering before-first-byte and after-first-byte failures.
  • Check whether fallback occurs only for configured HTTP statuses or also timeouts.
  • Verify compatibility for tools, structured output, vision and streaming deltas.
  • Do not infer a vendor's behavior from another gateway's API semantics.

Retry economics are part of reliability

Retries are not free merely because the final user sees one answer. Depending on provider and billing rules, a failed or timed-out attempt may still consume tokens or bill for work already performed. OpenRouter's published pricing currently says errored fallback attempts are not charged for model tokens on its marketplace path, with caveats for auxiliary services. That is a vendor-specific policy, not a universal statement about BYOK providers or every gateway.

Set an attempt ceiling, a total deadline and a maximum estimated cost for each logical task. Record every upstream attempt with its provider, model, status, usage class and elapsed time. A dashboard that only stores the successful attempt can understate latency and cost. For a user-facing application, one slow fallback may be worse than a prompt explicit error; measure task completion rate alongside p95 response time and actual invoice impact.

  • Bound retries per request and across an entire agent mission.
  • Do not retry authentication failures as though they were transient outages.
  • Respect provider rate-limit signals and avoid synchronized retry storms.
  • Report logical-task cost separately from individual attempt cost.

A concrete acceptance test for a production buyer

Prepare a representative set of tasks: plain text, a strict JSON schema, a tool-call request and a streaming answer. Run each directly against the primary model and then through the gateway with the same settings. Introduce controlled failures before the provider response and after the first streamed chunk. Verify that clients receive the documented status and that they never silently combine incompatible answers.

Repeat under concurrency with an intentionally tight deadline and budget. Check whether retry requests are bounded, whether fallback models are allowlisted, whether provider identity is visible, and whether the gateway returns a complete accounting of attempts. For structured output, validate the actual schema; a backup that returns fluent prose instead of required JSON is a failed task even if the HTTP request returned 200.

  • Inject 429, 5xx, timeout and connection-reset cases in a non-production fixture.
  • Break the stream after several chunks and inspect client-visible behavior.
  • Run tool-call and JSON-schema compatibility tests across every fallback target.
  • Compare direct and gateway paths for p50/p95 latency, accepted outputs and costs.

AetherGate's stated boundary, and how to verify it

AetherGate's public guides state that it does not silently replay a stream on another model after a live answer has started. This is a narrower and more defensible claim than 'seamless streaming failover.' Its pricing page describes compatible failover as part of the Team offering, but buyers should test the exact route, supported provider endpoints, response framing and error semantics in their own environment.

Ask any vendor, including AetherGate, for the current implementation and a repeatable test run. An architecture diagram, feature checkmark or internally reported latency figure is not enough. The buying decision should turn on what the caller actually receives when an upstream request fails at the least convenient moment.

Decision rule: favor predictable failure over invisible corruption

For chat-only interfaces, a visible interruption with a retry button may be acceptable. For financial analysis, structured extraction or tool-driven automation, partial responses and duplicate actions can create much larger problems. Define the failure contract with the application team before choosing a gateway, including whether the client can restart a logical task and what state must be persisted.

The strongest production gateway is not necessarily the one that attempts the most retries. It is the one that applies the team's authorized policy, preserves output correctness, keeps spending bounded and makes failure diagnosable. Put those criteria in the acceptance test and compare vendors on observed results.

Sources

Evaluate the gateway on your own workload

Compare an actual gateway request with your direct-provider baseline. Review pricing, security controls and measured behavior before migrating production traffic.

Gateway evaluation resources

Continue from the concept to a practical cost, security or migration decision.

Continue reading

Related gateway comparisons

Frequently asked questions

Can an AI gateway switch models after streaming has begun?

Some products may support application-specific recovery, but transparent mid-stream model replacement is not safe to assume. A second model can repeat or contradict already emitted text, and tool-call fragments may not be compatible.

What is the difference between retry and fallback?

A retry attempts the same logical operation again, often within the same model group. A fallback switches to another configured target or model. Exact behavior is vendor- and policy-dependent.

Does a failed model attempt always cost nothing?

No. Charging depends on the provider, gateway, stage of failure and auxiliary services. Check the provider invoice and the vendor's documented policy.

Put the advice into practice

Optimize AI work with Foreman

Give the team a job. Foreman weighs the work, model capabilities and price, then explains its choices. Enable web tools for public research. Review, edit or decline proposed actions before they run.

Give Foreman a job →
Technical details

Reasoning-model task routing, persisted specialist/reviewer workflows, web search, Chromium browsing and approval-gated browser/HTTP writes. Fresh public sessions; no signed-in accounts or arbitrary code execution.

Set a limit before the work starts

Per-key spending controls. Each request reserves its estimated cost before it's sent, and parallel calls are only admitted while those reservations fit under the cap.

Set spending controls →
Technical details

Atomic catalog-priced cost reservations, per-key caps, and retained reservations for uncertain charges. Provider invoices, taxes and special rates can differ.