Fallback Management API
This page documents the 3 gateway endpoints tagged Fallback Management 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 |
|---|---|---|
| POST | /fallback | Set the fallbacks of one model |
| GET | /fallback/{model} | Read the fallbacks of one model |
| DELETE | /fallback/{model} | Remove the fallbacks of one model |
Endpoints
POST /fallback
Set the fallbacks of one model
Create or replace the fallback list of one model without sending the whole router settings. The models are tried in order once every retry on the primary model has failed. fallback_type general covers any error, context_window prompts too long for the model and content_policy provider content filter refusals. Every model named must exist on the gateway and a model cannot be its own fallback. The list is saved in the router settings the Fallbacks tab edits, applied at once and written to the audit log. Only the stored router settings are rewritten, so values from the config file never reach the database, and a list the config file sets is refused with a 400 because the file would win again on the next restart.
Request body (application/json, schema FallbackCreateRequest):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name to configure fallbacks for (e.g., 'gpt-3.5-turbo') |
fallback_models | array of string | Yes | List of fallback model names in order of priority |
fallback_type | enum: "general", "context_window", "content_policy" | No | Type of fallback: 'general' (default), 'context_window', or 'content_policy' |
Example request:
curl -X POST "http://localhost:4000/fallback" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"fallback_models": [
"gpt-6.1-sol"
],
"fallback_type": "general"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The saved fallback list, with whether it was created or updated. | application/json FallbackResponse |
| 400 | Invalid fallback models: ['gpt-missing'] or Model 'claude-sonnet-5-5' cannot be its own fallback or Database storage not enabled. Set 'STORE_MODEL_IN_DB=True' in your environment to use this feature. or router_settings key 'fallbacks' is set in the config file and cannot be changed here. | application/json ErrorDetail |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 404 | Model 'claude-sonnet-5-5' not found in router | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Router not initialized | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name |
fallback_models | array of string | Yes | List of fallback model names |
fallback_type | string | Yes | Type of fallback |
message | string | Yes | Success message |
GET /fallback/{model}
Read the fallbacks of one model
Return the fallback list of one model for the given fallback_type, as the router applies it right now, whether it came from the config file, the Fallbacks tab or POST /fallback. A model with no fallbacks of that type is a 404.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | path | string | Yes | |
fallback_type | query | enum: "general", "context_window", "content_policy" | No |
Example request:
curl -X GET "http://localhost:4000/fallback/model-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The fallback list the router applies right now. | application/json FallbackGetResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 404 | No general fallbacks configured for model 'claude-sonnet-5-5' | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Router not initialized | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name |
fallback_models | array of string | Yes | List of fallback model names |
fallback_type | string | Yes | Type of fallback |
DELETE /fallback/{model}
Remove the fallbacks of one model
Delete the stored fallback list of one model for the given fallback_type. The router stops falling back for that model at once and the change is written to the audit log. Needs STORE_MODEL_IN_DB=True, and a list the config file sets is refused with a 400.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | path | string | Yes | |
fallback_type | query | enum: "general", "context_window", "content_policy" | No |
Example request:
curl -X DELETE "http://localhost:4000/fallback/model-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The fallback list was removed. | application/json FallbackDeleteResponse |
| 400 | Database storage not enabled. Set 'STORE_MODEL_IN_DB=True' in your environment to use this feature. or router_settings key 'fallbacks' is set in the config file and cannot be changed here. | application/json ErrorDetail |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 404 | No general fallbacks configured for model 'claude-sonnet-5-5' | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Router not initialized | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name |
fallback_type | string | Yes | Type of fallback |
message | string | Yes | Success message |