Router Settings page
The Router Settings page controls how the gateway picks a deployment for each request and holds a set of gateway-wide general settings. Open it at /ui/router-settings. It sits in the left nav under Settings, then Router Settings. The nav shows it to the proxy admin roles (proxy_admin and proxy_admin_viewer, which the UI reports as the session roles "Admin" and "Admin Viewer"). Org admins see the Settings group but not this item, because its role list does not include the "Org Admin" session role. The page has no license gate.
The page has seven tabs, Loadbalancing, Routing Groups, Fallbacks, Prompt Caching, Structured Output, General and Adaptive Router. Loadbalancing opens first. Every write on this page goes to a backend route that only accepts the proxy_admin role, so a proxy admin viewer can open every tab and read the values but any save is refused by the gateway.
A real-world scenario
A provider's East US deployment keeps timing out at peak hours while the West US one is fine. The admin switches the routing strategy to latency based routing, sets two retries, and adds a fallback from the model group to a second provider, all from this page and without a restart.
Steps
-
Open Settings, then Router Settings, or go to
/ui/router-settings. The Loadbalancing tab opens. -
Pick
latency-based-routingunder Routing Strategy, set the retries under Reliability & Retries, and click Save Changes. The page sends the same update as:curl -X POST http://localhost:4000/config/update \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"router_settings": {"routing_strategy": "latency-based-routing", "num_retries": 2}}'/config/updateis the route the Admin UI saves settings with. It is deliberately left out of the published API reference and the Postman collection, because it can rewrite any gateway setting and we do not publish a full map of it. It stays supported for scripts that need it, this page is its reference, and the errors below are the full list. It takes any ofrouter_settings,general_settings,spanway_settingsandenvironment_variables, writes only the sections and keys you send, answers{"message": "Config updated successfully"}, refuses a key the config file already sets or an unknown router setting with400, and is open to proxy admins only. Read the result back withGET /router/settings. -
Open the Fallbacks tab, add a fallback from the model group to another one and save.
-
Send a request and check the headers or the Logs page to see which deployment answered.
Expected result
A toast confirms the save, the values stay after a reload, and new requests are routed with the new strategy and retries.
Loadbalancing tab
This tab edits the router_settings section. Values load from the gateway when the page opens, and the field labels and descriptions come from the gateway's router settings catalogue, so the text you see next to each control is the gateway's own description. Nothing on this tab is saved until you press Save Changes.
Profiles
When the gateway offers profiles, a Profiles section appears at the top with the note "Start from a profile. Only the settings it lists change, and nothing is saved until you press Save Changes." Each profile is a button. Hover a button to see its description.
| Profile | Settings it changes |
|---|---|
| Balanced | Routing strategy simple-shuffle, 2 retries, 3 allowed fails, 30 second cooldown, pre-call checks on. |
| Low latency | Routing strategy latency-based-routing, 1 retry, 30 second timeout, 2 allowed fails, 15 second cooldown. |
| Cost saver | Routing strategy cost-based-routing, 2 retries, pre-call checks on. |
| High availability | Routing strategy least-busy, 3 retries, 1 allowed fail, 60 second cooldown, retry after 1 second, pre-call checks on. |
Clicking a profile opens a preview with the profile description and a table with the columns Setting, Current and Profile that lists only the settings that would change. A value that is not set shows as unset. If your settings already match, the preview says "Your settings already match this profile." and the apply button is disabled. Apply followed by the profile name copies the profile values into the form below. Cancel closes the preview without changing anything. Applying a profile still does not save. Press Save Changes afterwards.
Routing Settings
| Control | Type | What it does |
|---|---|---|
| Routing Strategy | Dropdown | Picks how the router chooses among deployments of a model group. Each option shows the strategy name and the gateway's description of it. The dropdown only appears when the gateway returns a list of strategies. |
| Enable Tag Filtering | Toggle | Turns tag based routing on or off. A Learn more link appears when the gateway provides one. |
| Fit To Context | Toggle | When on, the gateway drops the oldest middle turns of a conversation that does not fit the selected deployment's input window. Turning it on from the UI sets the middle_out strategy. If config.yaml configures the summarize strategy, a note names the compactor model ("Summarizing with ... set in config.yaml. Turning this off clears it."), and turning the toggle off removes that configuration. |
Latency-Based Configuration
This section appears only while Routing Strategy is set to latency-based-routing. It shows one text field per routing strategy argument. When no arguments are stored yet it offers two fields.
| Field | Default shown | What it does |
|---|---|---|
| ttl | 3600 | Sliding window in seconds used to average a deployment's latency. |
| lowest latency buffer | 0 | Shuffle between deployments within this percentage of the lowest latency. 0 always picks the lowest latency deployment. |
Only these two fields are sent on save, as numbers, and only when they have a value.
Reliability & Retries
The Reliability & Retries section lists every router setting in the gateway's catalogue that no other tab owns, with the value the gateway is using right now, so a setting that was never set still appears with its default or empty. Settings managed on other tabs (fallbacks, context window fallbacks, content policy fallbacks, routing groups, retry policies, routing strategy, tag filtering and fit to context) are left out. A Learn more link appears under a setting when the gateway provides a docs link for it.
| Setting type | Control | How it is saved |
|---|---|---|
| Whole numbers and seconds (for example Number of Retries, Timeout, Allowed Fails, Cooldown Time, Retry After, Deployment Affinity TTL, Health Check Staleness Threshold) | Text field | Sent as a number. An empty field clears the setting, and text that is not a number is ignored so the old value is kept. |
| Toggles (for example Enable Pre-call Checks, Enable Weighted Failover, Route On Health Checks, Ignore Transient Health Check Errors, Disable Cooldowns) | Switch | Sent as true or false. |
| JSON settings (for example Model Group Alias, Allowed Fails Policy, Provider Budgets, Model Group Affinity) | Text field | Must be JSON. An empty field clears the setting and invalid JSON is ignored so the old value is kept. |
| Lists of names (for example Default Fallbacks) | Text field | Comma-separated names, or a JSON array. An empty field clears the setting. |
| Pre-call Checks | One checkbox per check the gateway supports | The checked checks are sent as a list, in the gateway's order. Clearing every box sends an empty list, which turns the runtime-toggleable checks off. |
| Text (for example Tag Routing Prefix) | Text field | Sent as typed. |
The word null in any text field clears that setting. Clearing removes the value saved in the database, and the audit log row shows the old value. The running gateway keeps the value it already uses until it restarts, then it uses the config.yaml value or the default. A setting that config.yaml sets cannot be cleared here and is refused with 400. Settings whose description ends with "applied the next time the gateway starts" are stored in the database when you save and read at the next start, because the router builds them once. The others apply as soon as the save succeeds.
A real-world example. A team wants requests for any model group without its own fallback chain to end up on gpt-6.1-sol, and wants rate limited deployments skipped before the call instead of after a retry.
- Open
/ui/router-settingsand stay on the Loadbalancing tab. - In Reliability & Retries, type
gpt-6.1-solinto Default Fallbacks. - Tick
enforce_model_rate_limitsunder Pre-call Checks. - Press Save Changes. The toast reads "router settings updated successfully".
The same change over the API:
curl -X POST http://localhost:4000/config/update \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"router_settings": {"default_fallbacks": ["gpt-6.1-sol"], "optional_pre_call_checks": ["enforce_model_rate_limits"]}}'
GET /router/settings then reports both values under current_values, and GET /router/fields lists every setting the section can show with its type, description and docs link.
Actions
| Button | What it does |
|---|---|
| Reset | Reloads the browser page, which throws away unsaved edits on every tab. It does not change anything on the gateway. |
| Save Changes | Sends only the router settings you changed on this tab, so it never resends values loaded with the page and cannot undo a save made on another tab. With no changes it shows "Nothing to save. Change a setting on this tab first." and sends nothing. A success toast says "router settings updated successfully". A failure shows "Failed to update router settings" with the error. The gateway rejects settings it does not support and refuses to overwrite values that config.yaml owns. |
Routing Groups tab
A routing group puts a set of models behind one group, each with its own routing strategy. The tab shows a search box, a table and the group editor. Saving or deleting a group writes only the routing groups setting, so it does not touch the other router settings.
| Control | What it does |
|---|---|
| Search groups... | Filters the table by group name, strategy or member model. The Clear search button empties the box. |
| Refresh | Reloads the routing groups from the gateway. |
| Create Group | Opens the Create Routing Group dialog. |
| Result count | "Showing N results" for the current filter. |
| Column | Meaning |
|---|---|
| Group Name | The group name. Click it to expand the row. Sortable. |
| Models | The member models. |
| Strategy | The routing strategy, shown as Simple Shuffle, Least Busy, Usage Based, Latency Based or Priority. Other strategies show their raw name. Sortable. |
| Actions | A menu with Edit and Delete. |
An expanded row shows "How routing works for this group" and example requests in three tabs, cURL, Python (OpenAI SDK) and JavaScript (OpenAI SDK). For a priority group the example calls the group name. For other strategies callers keep requesting a member model by name and the example uses the first member model. The base URL in the examples is the gateway's configured API doc base URL or proxy base URL, falling back to the browser's address. The examples read the key from the SPANWAY_API_KEY environment variable and never include a real key.
Create Routing Group and Edit dialogs
| Field | Type | Rules and effect |
|---|---|---|
| Group Name | Text, placeholder fast-chat | Required, at most 64 characters, and must not match another group's name (case is ignored). It cannot be changed after the group is created. |
| Models | Multi select | Required, at least one model. The options are the model groups on the gateway. A model may belong to only one non-priority group, and the dialog lists any model already claimed by another group. Models may belong to several priority groups. |
| Routing Strategy | Dropdown | Required. Defaults to the first strategy the gateway offers. The help text shows the strategy description. |
| Model Priorities | One number field per model | Shown only for the Priority strategy. Use 1 for the first choice, 2 for the next, and so on. Models with the same priority share traffic and unavailable models are skipped. Each selected model needs a whole number of 1 or more. A priority left over for a model you removed is marked "Model is not selected" and has a Remove button, and the dialog will not save until it is removed. |
| Strategy Arguments (JSON) | Text area | Shown only for latency-based-routing and usage-based-routing. Optional. If filled it must be valid JSON. |
Cancel closes the dialog. Create Group or Save Changes saves. The note at the bottom explains the effect. Models outside non-priority groups use the proxy's top-level routing strategy, and direct requests to a member of a priority group keep their existing routing behavior.
Delete routing group
Delete in the row menu opens "Delete routing group?". For a priority group it warns that calls to the group name stop working while direct requests to its member models keep their routing. For other groups it warns that the models fall back to the proxy's top-level routing strategy. Both say the action cannot be undone. Delete removes the group from the gateway's router settings. Cancel keeps it.
Fallbacks tab
Fallbacks tell the gateway which models to try, in order, when a model fails. Every save on this tab sends only the fallbacks, so it does not touch the other router settings.
| Column | Meaning |
|---|---|
| Model Name | The primary model, with its provider logo. |
| Fallbacks | The fallback chain in the order it is tried. |
| Actions | Test fallback, Edit fallback and Delete fallback icons. |
| Control | What it does |
|---|---|
| Add Fallbacks | Opens Configure Model Fallbacks. |
| Test fallback | Sends a real chat completion, "Hi, this is a test message", to the primary model with the gateway's fallback test flag set, using your dashboard session key. A toast shows which model you asked for and which model answered. Because the fallback model really answers, this can incur provider cost. |
| Edit fallback | Opens the same dialog for that one primary model. The primary model is locked. Save Changes is disabled while the chain is empty. |
| Delete fallback | Opens "Delete Fallback?" with the model name. Delete removes that model's fallback chain from the gateway. The dialog says "This action cannot be undone." |
Configure Model Fallbacks dialog
The dialog manages up to 5 fallback groups at a time, each in its own tab. The + button (Add fallback group) adds a group, and the x on a tab removes it. At least one group is required. Each group has two parts.
| Field | Rules and effect |
|---|---|
| Primary Model | Required. Pick from the model groups on the gateway. Until it is set, a warning reads "Select a model to begin configuring fallbacks" and the chain is disabled. |
| Fallback Chain | Required, up to 10 models. The primary model is not offered. Selected models are listed in the order they will be tried and can be removed with the x next to each. |
Save All Configurations adds the new groups to the existing fallbacks. If any group lacks a primary model or a fallback, an error says how many groups are incomplete and nothing is saved. Cancel discards the dialog.
Prompt Caching tab
The Prompt Caching card holds three settings. Each change is saved the moment you make it, and there is no separate save button.
| Control | Type | What it does |
|---|---|---|
| Automatic Anthropic prompt caching | Toggle | Adds cache control to the system prompt and the trailing turn for supported Claude models on Anthropic, AWS Bedrock, Vertex AI and Azure AI. The description warns that the cache is shared across callers on the same upstream credentials. |
| Cache lifetime (TTL) | Dropdown, 5m (default) or 1h | Disabled until automatic caching is on. Choosing 5m (default) clears the value so the provider default applies. The description notes that 1h doubles the cache write cost. |
| System messages first for OpenAI | Toggle | Moves system and developer messages to the front of OpenAI and Azure OpenAI chat completions requests so the provider's prompt cache prefix stays stable. |
Structured Output tab
The Structured Output Repair card sets the gateway default for chat completions that ask for JSON output. Keys, teams, deployments and requests can override it. Each change is saved immediately. If the save fails, the dropdown goes back to its previous value and an error toast appears.
| Control | Options | What it does |
|---|---|---|
| Repair mode | off (default), off, repair, retry, repair_and_retry | repair fixes common breakage locally, retry asks the model again with the validation error, and repair_and_retry does both. |
| Max correction retries | 1 (default), 0 to 5 | How many correction requests are allowed per request. Disabled unless Repair mode is retry or repair_and_retry. |
General tab
This tab is a table of gateway-wide general settings, such as request size limits, parallel request limits, file upload limits, data retention periods and region enforcement. Settings shown on the Prompt Caching and Structured Output tabs are left out. Text settings (for example the retention periods and required_model_region) show no editor in the Value column, so Update does nothing for them. Set those values in config.yaml or on the page that owns them. Pass-through endpoints are not listed here, so they cannot be reset from this tab. Manage them on the Models + Endpoints page. The store_prompts_in_spend_logs toggle is off by default, so request and response content is not kept. Turning it on starts storing content in spend logs and related tables, as What Spanway stores explains.
| Column | Meaning |
|---|---|
| Setting | The setting name, with the gateway's description under it. |
| Value | An editor that matches the setting type. Whole numbers get a number field, booleans a toggle, list settings a text field that takes comma-separated values, dollar amounts a field with a $ prefix, and choice settings a dropdown with Default. |
| Status | Where the current value comes from. |
| Action | Update saves the value in the row. The trash icon (Reset followed by the setting name) resets it. |
| Badge | Meaning |
|---|---|
| In DB | The value is stored in the database, set from the UI or the API. |
| In Config | The value comes from config.yaml or the environment. |
| Not Set | The setting uses its default. |
Update saves only that row. A success toast reads "Successfully updated value!". Clearing a list or choice setting and pressing Update resets it instead. The trash icon opens a confirmation titled Reset followed by the setting name, which says "This deletes the value saved in the database. The gateway then uses the value from the config file, or the default when the config file does not set one." Reset removes the database value and Cancel keeps it. A success toast reads "Field reset on proxy". If the reset fails, the dialog stays open with "The setting was not reset" and the error. Reset cannot be undone except by entering the value again. The gateway refuses to write or reset a setting that config.yaml owns.
Adaptive Router tab
Adaptive router state is a read-only view of what each adaptive router has learned. The numbers come from the gateway replica that answered, so replicas can differ, and the state keeps no prompt or response text. The How adaptive routing works link opens the adaptive router docs. Refresh reloads the state and reads "Refreshing..." while it works.
Each router gets a section named after it. A line states the quality and cost weights and how many pending updates are waiting, when the gateway reports them.
| Column | Meaning |
|---|---|
| Request type | The request category the router scored. |
| Model | The candidate model. |
| Samples | How many requests have been scored for that pair. |
| Estimated quality | The current quality estimate as a percentage. |
Empty, error and disabled states
On the Loadbalancing tab, the Routing Strategy dropdown is missing if the gateway returns no strategy list, and the Profiles section is missing if the gateway offers no profiles. On the Routing Groups tab, an empty table reads "No routing groups yet" with "Create a group to load-balance a set of models behind one name.", and the table shows "Loading routing groups…" while it loads. A save or delete that fails shows the gateway error in a toast and leaves the dialog open. On the Fallbacks tab, an empty list reads "No fallbacks configured. Add fallbacks to automatically try another model when the primary fails." A failed fallback save shows "Failed to update router settings" and the tab reloads the current fallbacks from the gateway.
The Prompt Caching, Structured Output and General tabs read from the gateway's general settings list, which needs a connected database. Without one, or when the request fails, those tabs stay empty and an error toast appears. Cache lifetime (TTL) is disabled until automatic caching is on, and Max correction retries is disabled unless the repair mode retries.
On the Adaptive Router tab, "Loading the adaptive router state..." shows while it loads. If no adaptive router is configured the tab says "No adaptive router is configured on this gateway. Add a model whose model is auto_router/adaptive_router to start one." If your role cannot read it, the tab says "Only proxy admins and admin viewers can see the adaptive router state." A router that has seen no traffic shows "No traffic has reached this router yet, so every model still has its starting score." If the response has an unexpected shape, the tab suggests reading GET /adaptive_router/state directly.
Differences by role and license
Only the proxy admin roles see this page in the nav. The gateway enforces writes on its side. Saving router settings, routing groups and fallbacks (/config/update) and updating or resetting general settings (/config/field/update and /config/field/delete) require the proxy_admin role. Reading router settings, the general settings list and the adaptive router state is allowed for proxy admins and proxy admin viewers.
A proxy admin viewer still sees most write controls, including Save Changes, Create Group, the fallback actions, the prompt caching toggles and Update, because the UI does not hide them for view-only sessions. Pressing them returns an error from the gateway and nothing changes. For view-only sessions the General tab also hides secret values, because the gateway redacts them for anyone but a proxy admin. There is no license requirement on this page.
Errors
| What you see | What it means | Fix |
|---|---|---|
| A toast with a permission error on save | The session is a proxy admin viewer, writes need proxy_admin. | Sign in as a proxy admin. |
| The Prompt Caching, Structured Output and General tabs are empty with an error toast | The gateway has no database, or the request failed. | Set DATABASE_URL and reload. |
| Routing Strategy is missing | The gateway returned no strategy list. | Reload, and check the gateway log for the error. |
| "No adaptive router is configured on this gateway" | No model uses auto_router/adaptive_router. | Add one, see adaptive router. |
403 Only proxy admins can update config from /config/update | The key or session is not a proxy admin. | Use a proxy admin key. |
400 Unsupported router settings: ... are not valid router settings | A key in router_settings is not a router setting, or is managed on another page. | Check the spelling against GET /router/fields. |
400 router_settings key '...' is set in the config file and cannot be changed here. | config.yaml owns that key, so a saved value would never apply. | Change it in config.yaml, or remove it there first. |
400 with a routing_groups: or model_priorities message | A routing group is broken, see routing groups. | Fix the group named in the message. |
400 Context compaction: context_fit must be true, false, "middle_out" or an object with a strategy | Fit To Context got a value it does not understand. | Send true, false or "middle_out". |
400 Authentication Error, No DB Connected | The gateway has no database, so it cannot store the change. | Set DATABASE_URL and restart. |