Routing presets API
This page documents the 10 gateway endpoints tagged routing presets in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| GET | /routing/presets | List the routing presets of a scope |
| POST | /routing/presets | Create a routing preset or save a new version |
| GET | /routing/presets/{slug} | Read a routing preset |
| DELETE | /routing/presets/{slug} | Delete a routing preset |
| GET | /routing/presets/{slug}/versions | List the versions of a routing preset |
| POST | /routing/presets/{slug}/rollback | Roll a routing preset back |
| GET | /routing/tier_policies | List the budget tier policies |
| GET | /routing/tier_policies/{scope_type}/{scope_id} | Read a budget tier policy |
| PUT | /routing/tier_policies/{scope_type}/{scope_id} | Assign a budget tier policy |
| DELETE | /routing/tier_policies/{scope_type}/{scope_id} | Remove a budget tier policy |
Endpoints
GET /routing/presets
List the routing presets of a scope
List the latest version of every routing preset in a scope, global or a team id.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
scope | query | string | No |
Example request:
curl -X GET "http://localhost:4000/routing/presets" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Preset versions, newest first. | application/json RoutingPresetList |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read presets of that scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
presets | array of RoutingPresetVersion | Yes | Presets |
POST /routing/presets
Create a routing preset or save a new version
Create a routing preset or save a new version of it. Global presets need a proxy admin, team presets a proxy admin or an admin of that team. A team preset cannot reuse a global preset's name. Requests reference the preset as @preset/<slug> and always get the newest version.
Request body (application/json, schema RoutingPresetWrite):
| Field | Type | Required | Description |
|---|---|---|---|
slug | string | Yes | Slug |
scope | string | No | Scope |
config | PresetConfig | Yes |
Example request:
curl -X POST "http://localhost:4000/routing/presets" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"slug": "eu-fast",
"scope": "global",
"config": {
"models": [
"gpt-5.6",
"claude-sonnet-5-5"
],
"provider": {
"only": [
"azure",
"bedrock"
],
"sort": "throughput"
},
"params": {
"temperature": 0.2,
"max_tokens": 2000
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The newest version of the preset. | application/json RoutingPresetVersion |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not change presets of that scope. Read-only roles are refused by the route check with a plain text detail | application/json ErrorDetail |
| 409 | The name is taken by the other scope, global or team | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
scope | string | Yes | Scope |
slug | string | Yes | Slug |
version | integer | Yes | Version |
config | PresetConfig | Yes | |
created_by | string or null | No | Created By |
created_at | string or null | No | Created At |
GET /routing/presets/{slug}
Read a routing preset
Read the latest version of a routing preset in a scope.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | Yes | |
scope | query | string | No |
Example request:
curl -X GET "http://localhost:4000/routing/presets/slug-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The newest version of the preset. | application/json RoutingPresetVersion |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read presets of that scope | application/json ErrorDetail |
| 404 | No preset with that name exists in the scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
scope | string | Yes | Scope |
slug | string | Yes | Slug |
version | integer | Yes | Version |
config | PresetConfig | Yes | |
created_by | string or null | No | Created By |
created_at | string or null | No | Created At |
DELETE /routing/presets/{slug}
Delete a routing preset
Delete a routing preset and hide its version history. Requests that reference it start failing with a 404 once each replica's preset cache expires.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | Yes | |
scope | query | string | No |
Example request:
curl -X DELETE "http://localhost:4000/routing/presets/slug-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The preset and how many versions were hidden. | application/json RoutingPresetDeleted |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not change presets of that scope. Read-only roles are refused by the route check with a plain text detail | application/json ErrorDetail |
| 404 | No preset with that name exists in the scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
scope | string | Yes | Scope |
slug | string | Yes | Slug |
deleted_versions | integer | Yes | Deleted Versions |
GET /routing/presets/{slug}/versions
List the versions of a routing preset
List every version of a routing preset, newest first, with who saved each one and when.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | Yes | |
scope | query | string | No |
Example request:
curl -X GET "http://localhost:4000/routing/presets/slug-123/versions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Preset versions, newest first. | application/json RoutingPresetList |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read presets of that scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
presets | array of RoutingPresetVersion | Yes | Presets |
POST /routing/presets/{slug}/rollback
Roll a routing preset back
Save an older version of a routing preset again as its newest version, so history is kept and requests pick the restored configuration up within the preset cache lifetime.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | Yes |
Request body (application/json, schema RoutingPresetRollback):
| Field | Type | Required | Description |
|---|---|---|---|
scope | string | No | Scope |
version | integer | Yes | Version |
Example request:
curl -X POST "http://localhost:4000/routing/presets/slug-123/rollback" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"scope": "global",
"version": 2
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The newest version of the preset. | application/json RoutingPresetVersion |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not change presets of that scope. Read-only roles are refused by the route check with a plain text detail | application/json ErrorDetail |
| 404 | The preset has no such version | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Presets need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
scope | string | Yes | Scope |
slug | string | Yes | Slug |
version | integer | Yes | Version |
config | PresetConfig | Yes | |
created_by | string or null | No | Created By |
created_at | string or null | No | Created At |
GET /routing/tier_policies
List the budget tier policies
List every budget tier policy with the share of its team or organization budget used and the tier that share selects. Only proxy admins and admin viewers can list them.
Example request:
curl -X GET "http://localhost:4000/routing/tier_policies" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every policy with its live budget tier. | application/json TierPolicyList |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read that policy | application/json ErrorDetail |
| 500 | Budget tier policies need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
policies | array of TierPolicyStatus | Yes | Policies |
GET /routing/tier_policies/{scope_type}/{scope_id}
Read a budget tier policy
Read the budget tier policy of one team or organization, with the share of its budget used and the tier that share selects right now.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
scope_type | path | enum: "team", "organization" | Yes | team or organization |
scope_id | path | string | Yes | The team id or organization id |
Example request:
curl -X GET "http://localhost:4000/routing/tier_policies/scope_type-123/scope_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The policy, the share of the budget used and the tier that share selects. | application/json TierPolicyStatus |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read that policy | application/json ErrorDetail |
| 404 | No policy is assigned to that team or organization | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Budget tier policies need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
policy | TierPolicy | Yes | |
budget_used_percent | number or null | Yes | Share of this team's or organization's own budget used, in percent. Empty without a budget |
budget_tier | enum: "economy", "balanced", "frontier" | Yes | The tier the budget used right now selects |
PUT /routing/tier_policies/{scope_type}/{scope_id}
Assign a budget tier policy
Assign or replace the budget tier policy of a team or organization. Each tier names a routing preset, and requests that use model @tier move to a cheaper preset as the budget used crosses each shift percentage. Team policies need a proxy admin or an admin of that team, organization policies a proxy admin. A team preset may be used by a team policy, an organization policy can only use global presets.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
scope_type | path | enum: "team", "organization" | Yes | team or organization |
scope_id | path | string | Yes | The team id or organization id |
Request body (application/json, schema TierPolicyWrite):
| Field | Type | Required | Description |
|---|---|---|---|
config | TierPolicyConfig | Yes |
Example request:
curl -X PUT "http://localhost:4000/routing/tier_policies/scope_type-123/scope_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"config": {
"presets": {
"frontier": "frontier-models",
"balanced": "balanced-models",
"economy": "economy-models"
},
"default_tier": "frontier",
"shifts": [
{
"at_percent": 75,
"tier": "balanced"
},
{
"at_percent": 90,
"tier": "economy"
}
]
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The policy, the share of the budget used and the tier that share selects. | application/json TierPolicyStatus |
| 400 | A tier names a routing preset that the scope cannot use | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not change the policy of that team or organization. Read-only roles are refused by the route check with a plain text detail | application/json ErrorDetail |
| 404 | The team or organization does not exist | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Budget tier policies need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
policy | TierPolicy | Yes | |
budget_used_percent | number or null | Yes | Share of this team's or organization's own budget used, in percent. Empty without a budget |
budget_tier | enum: "economy", "balanced", "frontier" | Yes | The tier the budget used right now selects |
DELETE /routing/tier_policies/{scope_type}/{scope_id}
Remove a budget tier policy
Remove the budget tier policy of a team or organization. Requests that use model @tier start failing with a 404, or fall through to the organization policy, once each replica's 30 second cache expires.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
scope_type | path | enum: "team", "organization" | Yes | team or organization |
scope_id | path | string | Yes | The team id or organization id |
Example request:
curl -X DELETE "http://localhost:4000/routing/tier_policies/scope_type-123/scope_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The policy that was removed. | application/json TierPolicyDeleted |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not change the policy of that team or organization. Read-only roles are refused by the route check with a plain text detail | application/json ErrorDetail |
| 404 | No policy is assigned to that team or organization | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Budget tier policies need a connected database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
scope_type | enum: "team", "organization" | Yes | Scope Type |
scope_id | string | Yes | Scope Id |