What you will have at the end
A Route, assistant-api, that answers chat completions for an application which holds nothing but an API key for the gateway. Behind it, two model instances: an on-premises model server as the primary and a cloud model as the fallback. The provider keys are typed once into the Plugin and stored at the gateway, masked in the Plugin’s page and in the audit log. When the primary answers 5xx, the same request is sent to the fallback within the same call, and Traffic Explorer names which provider answered each request, with the retry marked. This is the form-first counterpart of Fallback between two LLM providers, which tells the same story with more context.
Prerequisites
- A Route and a Consumer.
assistant-apiservesPOST /ai/chatwithkey-auth; the Consumersupport_assistantholds the key the application sends. - An on-premises model server with an OpenAI-compatible chat endpoint. The lab’s is
llm-onprem:8080, servingllama-3.3-70b-instruct, and it can be switched into a restarting state in which it answers 503. - A cloud provider account and its key, here Anthropic with
claude-haiku-5-5. The fallback calls below went to the real provider with the lab’s own key on a real account; the key went into the form once, is masked in every screenshot and in the audit log, and no part of it is printed here. - Traffic logging turned on under Traffic Explorer › Settings, and a role that may manage Routes. The screenshots below were taken as
nora.becker.
The two instances
Open the Route, Plugins, Add plugin, ai-proxy-multi. Its first setting, Instances, is a list edited as JSON; Use example fills in a two-instance skeleton. Each instance carries a name, a provider, a priority, a weight, its auth header and its options:
onprem-llama: provideropenai-compatible, priority 10, weight 100, the modelllama-3.3-70b-instructunder options, anAuthorizationheader under auth, and underoverridetheendpointof the on-premises server, because an OpenAI-compatible provider needs to be told where it lives.anthropic-haiku: provideranthropic, priority 0, weight 100, the model andmax_tokensunder options, and thex-api-keyheader under auth. A known provider needs no endpoint.
The higher priority is tried first; weight shares the traffic among instances of the same priority. One thing to know about the editor: while you edit, the keys are in the clear in it, as they are in any editor, and only roles that manage Routes reach the form. Once saved, the Plugin’s page shows them as dots.

When to fall back
Under Behavior, Fallback strategy is a set of checkboxes: http_429, http_5xx, instance_health_and_rate_limiting and rate_limiting. Tick http_5xx: a 5xx from the instance that was picked sends the request to the next one. The note under it says which combinations the engine accepts, and Fallback status codes adds codes of your own beside the ones the strategy names. Further down, Logging › Payloads and Summaries add the bodies, or the model, the duration and the token counts, to the record a logger Plugin on this Route writes; Fallback retry limit caps how many more instances a failed request may try.

Select Add plugin. The Plugins tab draws the request path: key-auth first, then ai-proxy-multi, then the token budget of the next article, and no Upstream at all, because the Plugin is the backend.

What the application sees
The application sends a chat completion with its gateway key and nothing else:
curl -X POST http://localhost:9281/ai/chat -H 'apikey: …' -H 'content-type: application/json' \
-d '{"messages":[{"role":"user","content":"Where is order ord-10421?"}]}'
### without a key
HTTP/1.1 401 Unauthorized
### with the key, primary up
HTTP/1.1 200 OK
model: llama-3.3-70b-instruct · "Order ord-10421 is open and will ship within two working days." · usage 48 + 17 tokens
The on-premises server was then switched into its restarting state, where it answers every completion with 503. The same call, unchanged:
### while the primary answers 503, the first of two calls
HTTP/1.1 200 OK · 2.6 s
model: claude-haiku-5-5 · "I can't look up order ord-10421. I don't have access to your order system…" · usage 18 + 256 tokens
### primary restored
HTTP/1.1 200 OK
model: llama-3.3-70b-instruct
The application saw three 200s and never learned that one of them came from another provider; the model name in the body is the only trace. The content differs, because the fallback model has no access to the lab’s order system, which is a reminder that a fallback answers with its own knowledge.
What Traffic Explorer shows
The Upstream node column is the evidence. The records of the primary name llm-onprem:8080 with latencies from 6 to 148 ms; the records of the fallback name api.anthropic.com:443 with 2.6 seconds and a +1, the retry mark: the request was handed to the primary first.

One of the fallback records, opened: the Timing tab reads Gateway 1 ms, Upstream 2.60 s, and the Upstream node line reads api.anthropic.com:443 · 2 attempts. The engine tried the on-premises instance, received the 503, and went to the fallback within the same request.

What the audit log keeps
Every save of the Plugin is a Route update with the whole block in the diff: the instances, their endpoints, models and priorities, and both auth headers as •••• on both sides. The record below is a later change, the Summaries switch turned on, and it shows the same masking on a one-line change.

What to do next
- Put a token budget on the Route, per Consumer: Token budgets per Consumer with ai-rate-limiting.
- Decide what counts as a failure:
http_5xxcovers an outage; addhttp_429if the cloud provider’s own limits should also send traffic to the other instance. - Providers and fallback are on AI Gateway and in the AI Gateway datasheet.
- Refuse or shape prompts before they reach either model: Prompt rules at the gateway; answer repeated ones without a call: Answer repeated prompts from a cache.