What NagaAI does with each request
Most models in the catalog are served by several providers. For every chat request NagaAI:- Takes the providers that serve the requested model and are healthy right now.
- Orders them by the routing strategy.
- Sends the request to the first one. If that provider fails with a timeout, a
5xx, a rate limit or an exhausted quota, NagaAI tries the next one, up to three attempts. NagaAI does not retry a400or422from a provider.
model field of the response is the NagaAI catalog id, whichever provider answered.
Because the provider can change from one request to the next, two identical requests can land on different providers. Latency, cache hits and exact wording can differ between them.
Strategies
A strategy changes the order in which NagaAI tries providers. It never removes a provider and never makes a request fail.
If you do not choose a strategy, NagaAI chooses one, and the response header below tells you which.
Strategies apply to
/v1/chat/completions, /v1/responses and /v1/messages. Images, audio, embeddings and moderation ignore them.
Choosing a strategy
There are three places to set one. When more than one is present, the first in this list wins.- The request body: a top-level
routingobject. - The
x-naga-routing-strategyrequest header. - The API key’s default, set through the API keys API.
In the request body
routing object works in all three chat formats. The value is case-sensitive. An unknown strategy or an unknown key inside routing fails with 400 invalid_request_error:
In a header
Use the header when you cannot change the body, for example in a tool that only lets you add headers.As a key default
Setdefault_routing_strategy when you create or update a key through the account API. Every request made with that key uses the strategy unless the body or the header names another. Send null in an update to go back to letting NagaAI choose.