Provider preferences
A model group often has several deployments behind one name, for example the same model on OpenAI and on Azure, or a cheap and a fast provider for an open-weights model. Provider preferences let the caller, the key and the team decide which of those deployments may serve a request and which one should be tried first. They run before the routing strategy picks a deployment, so every strategy (simple shuffle, least busy, usage, latency and cost based) only ever sees deployments the preferences allow.
The provider object and the model suffixes apply to /v1/chat/completions, /v1/responses and /v1/messages. Key and team defaults apply to those three and also to /cursor/chat/completions, /queue/chat/completions, /v1/completions, /v1/responses/compact and /v1/embeddings, including their /engines/{model} and /openai/deployments/{model} forms.
A real-world scenario
A research team calls gpt-5.6, which the gateway serves from both OpenAI and Azure. Their contract says research traffic must stay on Azure, and finance wants the cheapest deployment that qualifies. The admin stores provider preferences on the research team that allow only Azure and sort by price. From then on every request from the team's keys goes to the cheapest Azure deployment of the group, even when a developer forgets to ask for it, and a request that tries to reach OpenAI is refused.
Step by step
-
In the Admin UI open Teams, open the research team and click Edit Settings. In the Provider preferences field enter
azureunder Only these providers, pick Lowest price under Prefer and click Save Changes. For a new key the same section sits under Optional Settings in + Create New Key on Virtual Keys. -
Or set it with curl:
curl -X POST http://localhost:4000/team/update \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"team_id": "team-research", "provider_preferences": {"only": ["azure"], "sort": "price"}}' -
Send a request with one of the team's keys, and read the
x-spanway-model-idresponse header to see which deployment served it:curl -s -D - -o /dev/null http://localhost:4000/v1/chat/completions \-H "Authorization: Bearer $SPANWAY_TEAM_KEY" -H "Content-Type: application/json" \-d '{"model": "gpt-5.6", "messages": [{"role": "user", "content": "Summarize this ticket"}]}' | grep -i x-spanway-model-id
Expected result
Every request from the team's keys is served by an Azure deployment of gpt-5.6, the cheapest one first, and x-spanway-model-id names it. A request that adds "provider": {"only": ["openai"]} cannot widen what the team allows, so no deployment is left and the gateway answers 400. Only a proxy admin can change the stored preferences, and anyone else gets 403.
The provider object
Send a provider object next to model in the request body.
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6",
"messages": [{"role": "user", "content": "Summarize this ticket"}],
"provider": {
"only": ["azure", "openai"],
"sort": "price",
"max_price": {"prompt": 3, "completion": 12},
"allow_fallbacks": false
}
}'
| Field | Type | What it does |
|---|---|---|
order | list of strings | Try matching deployments in this order. Deployments that match no entry come after the listed ones. |
only | list of strings | Keep only deployments that match at least one entry. |
ignore | list of strings | Drop every deployment that matches an entry. |
sort | price, latency, throughput or exacto, or {"by": ..., "partition": "model"} | Prefer the cheapest, the lowest latency, the highest output tokens per second or the most reliable deployment. The object form is accepted for clients that send it. partition: "none" is rejected with a 400 because sorting across fallback models is not supported. |
max_price | {"prompt": number, "completion": number} | Drop deployments that cost more than this, in USD per million input (prompt) and output (completion) tokens. Either side may be left out. |
allow_fallbacks | boolean | false turns off model group fallbacks for the request and, together with order, drops deployments that match no order entry. |
require_parameters | boolean | true keeps only deployments that support every capability parameter the client sent, such as tools, response_format or reasoning_effort. |
quantizations | list of int4, int8, fp4, mxfp4, nvfp4, fp6, fp8, mxfp8, fp16, bf16, fp32, unknown | Keep only deployments served at one of these precisions. |
preferred_max_latency | seconds, or {"p50", "p75", "p90", "p99"} | Rank deployments whose measured latency is above the cutoff after the ones that meet it. A bare number is the p50 cutoff. |
preferred_min_throughput | tokens per second, or {"p50", "p75", "p90", "p99"} | Rank deployments whose measured throughput is below the cutoff after the ones that meet it. A bare number is the p50 cutoff. |
enforce_distillable_text | boolean | true keeps only deployments whose model terms allow using its output to train other models. |
An entry in order, only or ignore matches a deployment when it equals, ignoring case, the deployment's provider (for example openai, azure, bedrock, anthropic, hosted_vllm), its deployment id (model_info.id) or its model group name. The provider comes from custom_llm_provider when it is set and otherwise from the model prefix in spanway_params.model.
Unknown fields are rejected with a 400, so a typo never silently does nothing.
How the preferences pick a deployment
The gateway first filters the model group's deployments with only, ignore, max_price, require_parameters, quantizations, enforce_distillable_text and, when allow_fallbacks is false, order. If nothing is left, the request fails with a 400 that names the preference that removed the last deployment and lists the deployments it looked at.
{"error": {"message": "No deployment of model 'gpt-5.6' satisfies the provider preferences: provider.only ['bedrock'] matches none of the deployments: openai (id gpt-openai), azure (id gpt-azure)", "code": "400"}}
After health checks, cooldowns and tag routing have run, the gateway ranks what is left. The gateway keeps only the best ranked deployments, all of them when several tie, and the routing strategy balances between those. The ranking compares, in this order:
- The position in
order. - Support for
tools,response_formatandverbositywhen the request uses them andrequire_parametersis not set, so deployments that can honour them come first. This only applies when some provider preference is in effect for the request, so requests without preferences route exactly as before. - The preferred latency and throughput cutoffs. Deployments that meet every cutoff come first, then deployments with no measurements, then deployments that miss a cutoff.
sort.
An explicit order beats the cutoffs because it is the caller's strongest signal.
When the chosen deployment fails and the router retries, the retry moves on to the next deployment in the ranking instead of trying the same one again. Once every ranked deployment has failed, retries go back to the full filtered list.
Required parameters
require_parameters looks only at capability parameters the client put in the request body, captured before key, team or deployment defaults are merged, so a default temperature never excludes a reasoning model. Parameters a routing preset fills in don't count either. It reads tools, tool_choice, parallel_tool_calls, response_format, reasoning_effort, verbosity, logprobs, top_logprobs, seed, logit_bias, frequency_penalty, presence_penalty, top_p, temperature, stop, n, modalities, audio, prediction and web_search_options on /v1/chat/completions. On /v1/responses, reasoning counts as reasoning_effort, text.format as response_format and text.verbosity as verbosity. On /v1/messages, thinking counts as reasoning_effort, stop_sequences as stop and output_format as response_format. Fields the gateway adds itself, such as user and metadata, never count.
What a deployment supports comes from the provider's parameter list for its model. A deployment pointing an OpenAI compatible server at a custom api_base inherits the OpenAI list, which may claim more than the server supports, so declare the real list on the deployment with model_info.supported_openai_params. A deployment whose parameters are unknown is excluded when require_parameters is on.
When any layer sets require_parameters: true, a later layer cannot switch it off.
Quantizations
A deployment's precision is model_info.quantization when the admin set it, and otherwise the quantization field of its model in the model cost map. A deployment with neither matches only unknown. fp4 also matches mxfp4 and nvfp4, and fp8 also matches mxfp8. When several layers set quantizations, a deployment has to match every list.
Distillable text
enforce_distillable_text keeps deployments declared with model_info.distillable_text: true. A deployment that declares false or nothing is excluded, and the 400 lists each deployment with distillable_text=false or distillable_text=undeclared. With router_settings.use_curated_data_terms: true, a deployment that declares nothing uses the curated distillable_text value of its model, described below.
Prices
max_price and sort: "price" read input_cost_per_token and output_cost_per_token from the deployment's spanway_params or model_info, and fall back to the model cost map for the deployment's model (or its base_model). A deployment whose price is unknown never passes a max_price cap and sorts after every priced deployment.
Latency, throughput and reliability
Every successful call records the deployment's latency and throughput, and every provider side failure (a 5xx, a timeout or a connection error) counts against it. Rate limits and errors caused by the request don't count. Latency is the time to the first token for streamed responses and the whole call otherwise. Throughput is output tokens divided by the time spent generating them.
Measurements are kept as per minute histograms. latency, throughput and the preferred cutoffs read the p50, p75, p90 and p99 of the last five minutes, falling back to the last 30 minutes when a deployment had no traffic in the last five. Percentiles are read conservatively, latency at the top of its bucket and throughput at the bottom, so a deployment near a cutoff is treated as missing it.
When the gateway has a Redis cache configured, every replica adds its measurements to shared Redis hashes every two seconds and reads the other replicas' measurements back, so all replicas rank on the same numbers. Without Redis, or while Redis is unreachable, each replica keeps ranking on what it measured itself.
A deployment with no recorded calls yet ranks first for latency and throughput, so a new deployment gets measured instead of being skipped forever.
Reliability sort (exacto)
sort: "exacto" ranks deployments by the lower bound of the 95 percent Wilson interval on their success rate over the last 30 minutes, then by throughput. A deployment with 3 successes out of 3 calls therefore ranks behind one with 970 out of 1000. When the request has tools, only tool calling requests count, and a response whose tool call arguments are not a valid JSON object counts as a failure. It measures live traffic only. There is no benchmark score.
To keep deployments that lost the lead from being starved forever, about one in twenty requests that use exacto or preferred cutoffs goes to a deployment with fewer than 20 calls in the last 30 minutes, inside the best order position. Those requests re-measure it so it can win its place back.
Model suffixes
Four suffixes on the model name are shortcuts for common preferences. They can be combined, for example gpt-5.6:online:nitro, and when several sorting suffixes are used the last one wins.
| Suffix | Same as |
|---|---|
:nitro | "provider": {"sort": "throughput"}, plus the priority service tier where the deployment offers it |
:floor | "provider": {"sort": "price"}, plus the flex service tier where the deployment offers it |
:exacto | "provider": {"sort": "exacto"} |
:online | Turn on web search for this request |
An unknown suffix such as :thinking stays part of the model name, so the request fails the model lookup instead of quietly falling back to the base model. See Service tiers for how :nitro and :floor pick a tier.
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5.6:floor", "messages": [{"role": "user", "content": "hi"}]}'
The gateway strips the suffix before key and team model checks run, so a key allowed to call gpt-5.6 may call gpt-5.6:nitro. A model group whose configured name really ends in one of these suffixes keeps its full name and nothing is stripped. A sort in the provider object wins over the suffix.
:online adds the gateway's web search tool to the request and keeps only deployments whose provider is listed in the web search interception enabled_providers, so the gateway runs the search when the model asks for it. If web search interception is not configured, a :online request fails with a 400 explaining that.
Service tiers
Some providers serve the same model at a priority tier (faster, more expensive) and a flex tier (slower, cheaper), picked per request with service_tier. A deployment offers a tier when any of these holds, checked in this order.
- Its
spanway_params.service_tieris pinned. It then offers only that tier, and a pinneddefaultorautooffers none. - Its
model_info.service_tierslists the tier. This is the same field the Codex model catalog reads, and it accepts tier ids or{id, name, description}objects. When it is set, it is the full list. - Its
model_infoor the model cost map hasinput_cost_per_token_priorityorinput_cost_per_token_flexfor the model.
:nitro ranks deployments that offer priority first and sends service_tier: "priority" to the one it picks. :floor sorts flex capable deployments by their flex price and sends service_tier: "flex" to the one it picks. A deployment that doesn't offer the tier still serves the request at its normal tier, and on a retry the tier follows whichever deployment the retry lands on. Neither suffix ever replaces a service_tier the client sent.
A request can also send service_tier itself. flex keeps only flex capable deployments when the model group has at least one and routes normally when it has none. priority (or fast) ranks priority capable deployments first and falls back to the others. The value is forwarded unchanged, so send priority to providers that don't know fast. Any other value, such as default or a custom ultrafast, is forwarded without changing routing.
model_list:
- model_name: gpt-5.6
spanway_params:
model: openai/gpt-5.6
api_key: os.environ/OPENAI_API_KEY
model_info:
service_tiers: ["priority", "flex"]
In the Admin UI, the model add and edit forms on Models + Endpoints have a Service tiers field with a Priority and a Flex checkbox, which write model_info.service_tiers. Leave both unticked to fall back to the pinned tier or the model's priority and flex prices. Saving keeps any {id, name, description} objects and other tier ids already in the list, and a save that leaves the checkboxes as they were does not touch the field. Anyone who may edit the model may change it, and service tiers are part of the free gateway.
Calls are billed at the tier the provider's response reports, which can differ from the one requested. Latency and throughput for priority and flex calls are measured separately from normal calls, so :nitro ranks on how fast each deployment answers at the priority tier, and uses its normal speed until it has priority measurements. Reliability is counted once per deployment across every tier, so successes and failures at any tier feed the same success rate.
A flex request that hits a capacity error follows the normal retry and fallback policy.
Defaults on keys and teams
Proxy admins can store default preferences on a key or a team. Set provider_preferences when creating or updating either one, or set it in the Admin UI in the Provider Preferences section of the create form or of the key's or team's settings. The form edits every field above with median cutoffs for latency and throughput, and keeps values it can't show, such as a cutoff with several percentiles, unchanged when you save.
curl -X POST http://localhost:4000/key/generate \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"provider_preferences": {"ignore": ["openai"], "max_price": {"prompt": 5, "completion": 15}}}'
curl -X POST http://localhost:4000/team/update \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"team_id": "team-research", "provider_preferences": {"sort": "latency"}}'
The value is validated when it is saved and stored under the key's or team's metadata.provider_preferences. Only a proxy admin can set or change it. Anyone else who sends a different value, through provider_preferences or through metadata, gets a 403, while resending the stored value unchanged is accepted.
Preferences combine in this order: the team, then the key, then a routing preset, then the model suffix, then the request's provider object. Each later layer can narrow what an earlier one allows but never widen it.
onlylists all apply, so a deployment has to match the team's list, the key's list and the request's list.ignorelists add up.max_pricekeeps the lowest cap on each side.allow_fallbacks: false,require_parameters: trueandenforce_distillable_text: trueanywhere win.quantizationslists all apply.sort,orderand the preferred cutoffs from a later layer replace earlier ones, so a request can choose its own ranking inside what its key allows.- When an earlier layer sets
ordertogether withallow_fallbacks: false, that list keeps limiting the deployments. A laterordercan then only narrow it further, because a deployment has to match both lists.
The filters also apply when a request names a single deployment by its id, so calling an excluded deployment directly fails with the same 400. On the routes listed at the top of this page a request can therefore never reach a provider its key or team excluded, or a deployment priced above the key's cap. Other routes, such as image, audio and rerank, don't apply provider preferences.
Curated data terms
The model cost map and the provider list carry curated data terms taken from each provider's or model author's own published terms. A provider entry can declare data_retention and trains_on_data, and a model entry can declare data_retention, trains_on_data, distillable_text, quantization and self_hosted, which override the provider's values. Every curated value names its source and the date it was checked. Terms that depend on the account tier or on a contract stay undeclared. A model hosted by a third party is only marked distillable_text when both the model's licence and the host's own terms allow it, so no hosted model carries the value yet and you declare it on the deployment instead.
They are off for routing by default. Set router_settings.use_curated_data_terms: true to let a deployment that declares nothing in its model_info use them for data policies and enforce_distillable_text. Values the admin set on the deployment always win. A deployment never uses curated terms when its traffic may go to a server other than the provider the terms describe, which means when it sets api_base, when the gateway sets a global api_base, or when the provider's base URL variable is set, such as OPENAI_BASE_URL, OPENAI_API_BASE, ANTHROPIC_BASE_URL or ANTHROPIC_API_BASE. Quantization from the cost map is always used for quantizations, since it describes the model and not a contract.
/model/info returns the curated values that would apply to each deployment under model_info.curated_data_terms, with their source and as_of, so you can check them before turning the setting on. Deployments that would not use curated terms, for the reasons above, don't get the field.
router_settings:
use_curated_data_terms: true
Limits
- Without Redis, latency, throughput and reliability are measured per process and start empty after a restart.
max_pricehas norequestorimagecaps yet.- A key or team
max_pricealso applies to embeddings and legacy completions, so a deployment there whose price is not configured or in the cost map is excluded by any cap. only,ignoreandordermatch providers, deployment ids and model group names. They do not match regions or API bases. Use tag routing for that.- Preferences only choose between deployments of the requested model group. They never add a model the key cannot call.
Errors
| What you see | What it means | Fix |
|---|---|---|
400 No deployment of model '<model>' satisfies the provider preferences: <reason> | The preferences left no deployment, for example only names a provider the group does not have, or max_price excludes every deployment. The reason says which rule removed the last one. | Loosen the preferences, or add a deployment that meets them. |
400 Invalid request field 'provider': <field>: <problem> | The request's provider object breaks a rule, for example an unknown field or a wrong type. The key and team versions read Invalid key metadata.provider_preferences: ... and Invalid team metadata.provider_preferences: .... | Fix the field the message names. |
400 with max_price needs a prompt or completion cap in USD per million tokens or a percentile cutoff needs at least one of p50, p75, p90 or p99 | A max_price or a latency or throughput cutoff is empty. | Give it at least one value. |
400 with sort.partition 'none' (sorting across fallback models) is not supported, use 'model' or omit it | Sorting across fallback models is not offered. | Remove partition or set it to model. |
400 The ':online' model suffix needs web search interception, which is not enabled for any provider on this gateway. ... | The model name ends in :online and no provider has web search interception. | Ask the admin to configure websearch_interception_params, or drop the suffix. |
403 Only proxy admins can set provider_preferences on a key. (or team.) | Preferences on a key or team bound which providers and prices its holder can reach, so only a proxy admin may change them. | Ask a proxy admin. |
| A deployment with no price is never picked | Any max_price cap excludes deployments whose price is not configured. | Set the price on the deployment, see custom pricing. |
| Latency ordering looks random after a restart | Without Redis the measurements are per process and start empty. | Configure Redis. |
Logs
| Level | Line | Meaning | Action |
|---|---|---|---|
| WARNING | Deployment speed <operation> through Redis failed, using local speeds: ... | The shared latency and throughput measurements could not be read or written in Redis, so this process sorts on its own measurements for now. | Normal during a short Redis outage. Check the Redis settings if it repeats. |
Otherwise preferences write no log line. The deployment that answered is in the x-spanway-model-id header and on the Logs page, and a change to a key's or team's preferences writes an audit row for the key or team.
Keys and teams carry default preferences. In the Admin UI set them under Provider Preferences in the Optional Settings of + Create New Key on Virtual Keys, or in the Provider Preferences section of a team on Teams.
Related
- Data policy routing for retention and training rules.
- Tag routing for regions and API bases.
- Routing for the routing strategies.