Model management API
This page documents the 36 gateway endpoints tagged model 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 |
|---|---|---|
| GET | /models | List the models this key can call |
| GET | /v1/models | List the models this key can call |
| GET | /models/{model_id} | Get one model this key can call |
| GET | /v1/models/{model_id} | Get one model this key can call |
| GET | /v2/model/info | Page through every deployment with pricing, provider and access |
| GET | /v1/model/info | List every deployment with its parameters, pricing and capabilities |
| GET | /model/info | List every deployment with its parameters, pricing and capabilities |
| GET | /v1/model/deprecations | List deployed models with a deprecation date |
| GET | /model/deprecations | List deployed models with a deprecation date |
| GET | /model_group/info | Describe each model group with combined limits, prices and capabilities |
| POST | /reload/model_cost_map | Reload the price map now |
| POST | /schedule/model_cost_map_reload | Reload the price map on a schedule |
| DELETE | /schedule/model_cost_map_reload | Stop the scheduled price map reload |
| GET | /schedule/model_cost_map_reload/status | Show the price map reload schedule |
| GET | /model/cost_map/source | Show where the price map came from |
| PATCH | /model/{model_id}/update | Change some fields of a stored deployment |
| POST | /model/block | Stop a deployment from serving requests |
| POST | /model/unblock | Let a blocked deployment serve requests again |
| POST | /model/delete | Delete a stored deployment |
| POST | /model/new | Add a model deployment without a restart |
| POST | /model/update | Replace the parameters of a stored deployment |
| POST | /model_group/make_public | Choose which model groups the public hub and catalogue list |
| POST | /model_hub/update_useful_links | Set the useful links shown on the AI hub |
| GET | /auto_router/classifier/default_prompt | Get the built-in classifier prompt of an auto router |
| POST | /auto_router/classifier/default_prompt | Preview the classifier prompt for an edited tier set |
| POST | /access_group/new | Create a model access group |
| GET | /access_group/list | List model access groups |
| GET | /access_group/{access_group}/info | Read one model access group |
| PUT | /access_group/{access_group}/update | Replace the models of an access group |
| DELETE | /access_group/{access_group}/delete | Delete a model access group |
| GET | /access_group/{access_group}/budget | Read an access group's shared budget |
| PUT | /access_group/{access_group}/budget | Set an access group's shared budget |
| DELETE | /access_group/{access_group}/budget | Clear an access group's shared budget |
| POST | /auto_router/validate_complexity_router_config | Check an auto router config without saving it |
| POST | /auto_router/availability | Check which auto router options the license still allows |
| POST | /auto_router/test_routing | Preview which model an auto router would pick |
Endpoints
GET /models
List the models this key can call
The public model names the calling key, its team and its organization may use, in the OpenAI listing shape,
so any OpenAI client can discover what to send as model. Wildcard entries, family aliases and model
access groups the key can reach are included according to the query parameters. For pricing, mode and
limits use /model/info or /model_group/info.
Query string:
- client_version: Sent by Codex CLI (
?client_version=0.159.3) when it fetches a provider's model catalog. When present, the response is Codex's own catalog shape ({"models": [...]}) built from the same listing, with each model'smodel_info.service_tiersas its service tiers; absent, the OpenAI shape below is returned - include_metadata: Include additional metadata in the response with fallback information
- fallback_type: Type of fallbacks to include ("general", "context_window", "content_policy") Defaults to "general" when include_metadata=true
- scope: Optional scope parameter. Currently only accepts "expand". When scope=expand is passed, proxy admins, team admins, and org admins will receive all proxy models as if they are a proxy admin.
- healthy_only: When true, hide models whose backing deployments are all marked
unhealthy by background health checks. Set
general_settings.model_list_healthy_only: trueto apply this to every caller without the query parameter. Requiresbackground_health_checks: truein general_settings, plus eithermodel_list_healthy_onlyorenable_health_check_routingto keep deployment health state cached; without health state the listing is returned unfiltered (fail open). Models expanded from wildcard routes (e.g.openai/*) are not filtered, and nothing is hidden whenallowed_fails_policyis configured (cooldown remains the sole exclusion mechanism). Hiding is presentation-only: a hidden model can still be called directly.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
return_wildcard_routes | query | boolean or null | No | |
team_id | query | string or null | No | |
include_model_access_groups | query | boolean or null | No | |
only_model_access_groups | query | boolean or null | No | |
include_metadata | query | boolean or null | No | |
fallback_type | query | string or null | No | |
scope | query | string or null | No | |
healthy_only | query | boolean or null | No | |
client_version | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The public model names this key may call, in the OpenAI listing shape. | application/json ModelListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "list" | Yes | Object |
data | array of ModelInfoResponse | Yes | Data |
GET /v1/models
List the models this key can call
The public model names the calling key, its team and its organization may use, in the OpenAI listing shape,
so any OpenAI client can discover what to send as model. Wildcard entries, family aliases and model
access groups the key can reach are included according to the query parameters. For pricing, mode and
limits use /model/info or /model_group/info.
Query string:
- client_version: Sent by Codex CLI (
?client_version=0.159.3) when it fetches a provider's model catalog. When present, the response is Codex's own catalog shape ({"models": [...]}) built from the same listing, with each model'smodel_info.service_tiersas its service tiers; absent, the OpenAI shape below is returned - include_metadata: Include additional metadata in the response with fallback information
- fallback_type: Type of fallbacks to include ("general", "context_window", "content_policy") Defaults to "general" when include_metadata=true
- scope: Optional scope parameter. Currently only accepts "expand". When scope=expand is passed, proxy admins, team admins, and org admins will receive all proxy models as if they are a proxy admin.
- healthy_only: When true, hide models whose backing deployments are all marked
unhealthy by background health checks. Set
general_settings.model_list_healthy_only: trueto apply this to every caller without the query parameter. Requiresbackground_health_checks: truein general_settings, plus eithermodel_list_healthy_onlyorenable_health_check_routingto keep deployment health state cached; without health state the listing is returned unfiltered (fail open). Models expanded from wildcard routes (e.g.openai/*) are not filtered, and nothing is hidden whenallowed_fails_policyis configured (cooldown remains the sole exclusion mechanism). Hiding is presentation-only: a hidden model can still be called directly.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
return_wildcard_routes | query | boolean or null | No | |
team_id | query | string or null | No | |
include_model_access_groups | query | boolean or null | No | |
only_model_access_groups | query | boolean or null | No | |
include_metadata | query | boolean or null | No | |
fallback_type | query | string or null | No | |
scope | query | string or null | No | |
healthy_only | query | boolean or null | No | |
client_version | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/v1/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The public model names this key may call, in the OpenAI listing shape. | application/json ModelListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
object | "list" | Yes | Object |
data | array of ModelInfoResponse | Yes | Data |
GET /models/{model_id}
Get one model this key can call
Retrieve information about a specific model accessible to your API key.
Returns model details only if the model is available to your API key/team. Returns 404 if the model doesn't exist or is not accessible.
Follows OpenAI API specification for individual model retrieval. https://platform.openai.com/docs/api-reference/models/retrieve
Query parameters mirror /v1/models so the same caller context (team
scoping, health filtering, paused deployments) drives both endpoints; the
listing's public id must resolve to the same internal deployment here.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_id | path | string | Yes | |
team_id | query | string or null | No | |
healthy_only | query | boolean or null | No |
Example request:
curl -X GET "http://localhost:4000/models/model_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The model, when the key may call it. | application/json ModelInfoResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 404 | Model not found or not accessible to your API key | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
object | "model" | Yes | Object |
created | integer | Yes | Created |
owned_by | string | Yes | Owned By |
mode | string | No | Mode |
max_input_tokens | integer | No | Max Input Tokens |
max_output_tokens | integer | No | Max Output Tokens |
metadata | ModelInfoMetadata | No |
GET /v1/models/{model_id}
Get one model this key can call
Retrieve information about a specific model accessible to your API key.
Returns model details only if the model is available to your API key/team. Returns 404 if the model doesn't exist or is not accessible.
Follows OpenAI API specification for individual model retrieval. https://platform.openai.com/docs/api-reference/models/retrieve
Query parameters mirror /v1/models so the same caller context (team
scoping, health filtering, paused deployments) drives both endpoints; the
listing's public id must resolve to the same internal deployment here.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_id | path | string | Yes | |
team_id | query | string or null | No | |
healthy_only | query | boolean or null | No |
Example request:
curl -X GET "http://localhost:4000/v1/models/model_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The model, when the key may call it. | application/json ModelInfoResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 404 | Model not found or not accessible to your API key | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
object | "model" | Yes | Object |
created | integer | Yes | Created |
owned_by | string | Yes | Owned By |
mode | string | No | Mode |
max_input_tokens | integer | No | Max Input Tokens |
max_output_tokens | integer | No | Max Output Tokens |
metadata | ModelInfoMetadata | No |
GET /v2/model/info
Page through every deployment with pricing, provider and access
Paginated model metadata for proxy deployments (pricing, provider, team access).
Returns configured router deployments with enriched model_info (costs, provider,
context window, etc.). Sensitive fields such as API keys and api_base are omitted.
Query parameters:
model: Filter to a single public model_name.
user_models_only: When true, only return models created by the calling user.
include_team_models: When true, populate access_via_team_ids and direct_access
on each model and filter to deployments the caller can use.
page / size: Pagination controls (defaults: page=1, size=50).
search: Case-insensitive partial match on model name or team public name.
modelId: Return a single deployment by Spanway model id.
teamId: Filter to models with direct access or team membership for this team id.
sortBy / sortOrder: Sort by model_name, created_at, updated_at, costs, or status.
access_group: Only return deployments in this model access group.
wildcard_only: Only return deployments whose model_name contains *.
Example request:
curl -X GET 'http://localhost:4000/v2/model/info?include_team_models=true&page=1&size=50' \
--header "Authorization: Bearer $SPANWAY_MASTER_KEY"
Example response:
{
"data": [
{
"model_name": "gpt-4",
"spanway_params": {"model": "openai/gpt-4.1"},
"model_info": {
"id": "abc123",
"spanway_provider": "openai",
"access_via_team_ids": ["team-1"],
"direct_access": true
}
}
],
"total_count": 1,
"current_page": 1,
"total_pages": 1,
"size": 50
}
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | query | string or null | No | Specify the model name (optional) |
user_models_only | query | boolean or null | No | Only return models added by this user |
include_team_models | query | boolean or null | No | Return all models across all teams user is in. |
debug | query | boolean or null | No | |
page | query | integer | No | Page number |
size | query | integer | No | Page size |
search | query | string or null | No | Search model names (case-insensitive partial match) |
modelId | query | string or null | No | Search for a specific model by its unique ID |
teamId | query | string or null | No | Filter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids |
sortBy | query | string or null | No | Field to sort by. Options: model_name, created_at, updated_at, costs, status |
sortOrder | query | string or null | No | Sort order. Options: asc, desc |
exclude_auto_routers | query | boolean or null | No | Omit auto-router deployments (spanway model prefixed auto_router/). They select among deployments rather than being deployments themselves, so a caller rendering a deployment list can leave them out. Defaults to false, |
access_group | query | string or null | No | Only return deployments whose model_info.access_groups contains this access group |
wildcard_only | query | boolean or null | No | Only return wildcard deployments, i.e. those whose model_name contains * |
Example request:
curl -X GET "http://localhost:4000/v2/model/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of deployments with their enriched model_info and the paging totals. | application/json ModelInfoPageResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | LLM Model List not loaded in. Make sure you passed models in your config.yaml or on the Spanway Admin UI. - https://docs.spanway.ai/docs/proxy/configs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of DeploymentInfo | Yes | Data |
total_count | integer | Yes | Total Count |
current_page | integer | Yes | Current Page |
total_pages | integer | Yes | Total Pages |
GET /v1/model/info
List every deployment with its parameters, pricing and capabilities
Provides more info about each model in /models, including config.yaml descriptions (except api key and api base)
What to send:
spanway_model_id: the value of the x-spanway-model-id response header of an earlier request.
- When spanway_model_id is passed, it will return the info for that specific model
- When spanway_model_id is not passed, it will return the info for all models
- include_team_models: When true, filter to deployments the caller can use (same as /v2/model/info).
- teamId: Filter to models accessible by the given team.
- healthy_only: When true, hide models whose backing deployments are all marked
unhealthy by background health checks, matching `/v1/models?healthy_only=true`.
Set `general_settings.model_list_healthy_only: true` to apply this to every
caller without the query parameter. Requires `background_health_checks: true`,
plus either `model_list_healthy_only` or `enable_health_check_routing` to keep
deployment health state cached; without health state the listing is returned
unfiltered (fail open). Ignored when `spanway_model_id` is passed, since that
is a direct lookup of one deployment rather than a listing. Hiding is
presentation-only: a hidden model can still be called directly.
Each model in the list response includes model_info.access_via_team_ids and
model_info.direct_access when the proxy database is connected.
What you get back:
A JSON response whose data list holds one entry per model.
Example Response:
{
"data": [
{
"model_name": "fake-openai-endpoint",
"spanway_params": {
"api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
"model": "openai/fake"
},
"model_info": {
"id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af",
"db_model": false
}
}
]
}
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway_model_id | query | string or null | No | |
include_team_models | query | boolean or null | No | When true, filter to deployments the caller can use via direct access or team membership. |
teamId | query | string or null | No | Filter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids |
healthy_only | query | boolean or null | No |
Example request:
curl -X GET "http://localhost:4000/v1/model/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every deployment the caller may see, with secrets removed and pricing, mode and limits filled in. | application/json ModelInfoListResponse |
| 400 | Model id = 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on spanway proxy | application/json ProxyError |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | LLM Model List not loaded in. Make sure you passed models in your config.yaml or on the Spanway Admin UI. - https://docs.spanway.ai/docs/proxy/configs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of DeploymentInfo | Yes | Data |
GET /model/info
List every deployment with its parameters, pricing and capabilities
Provides more info about each model in /models, including config.yaml descriptions (except api key and api base)
What to send:
spanway_model_id: the value of the x-spanway-model-id response header of an earlier request.
- When spanway_model_id is passed, it will return the info for that specific model
- When spanway_model_id is not passed, it will return the info for all models
- include_team_models: When true, filter to deployments the caller can use (same as /v2/model/info).
- teamId: Filter to models accessible by the given team.
- healthy_only: When true, hide models whose backing deployments are all marked
unhealthy by background health checks, matching `/v1/models?healthy_only=true`.
Set `general_settings.model_list_healthy_only: true` to apply this to every
caller without the query parameter. Requires `background_health_checks: true`,
plus either `model_list_healthy_only` or `enable_health_check_routing` to keep
deployment health state cached; without health state the listing is returned
unfiltered (fail open). Ignored when `spanway_model_id` is passed, since that
is a direct lookup of one deployment rather than a listing. Hiding is
presentation-only: a hidden model can still be called directly.
Each model in the list response includes model_info.access_via_team_ids and
model_info.direct_access when the proxy database is connected.
What you get back:
A JSON response whose data list holds one entry per model.
Example Response:
{
"data": [
{
"model_name": "fake-openai-endpoint",
"spanway_params": {
"api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
"model": "openai/fake"
},
"model_info": {
"id": "112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af",
"db_model": false
}
}
]
}
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway_model_id | query | string or null | No | |
include_team_models | query | boolean or null | No | When true, filter to deployments the caller can use via direct access or team membership. |
teamId | query | string or null | No | Filter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids |
healthy_only | query | boolean or null | No |
Example request:
curl -X GET "http://localhost:4000/model/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every deployment the caller may see, with secrets removed and pricing, mode and limits filled in. | application/json ModelInfoListResponse |
| 400 | Model id = 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on spanway proxy | application/json ProxyError |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | LLM Model List not loaded in. Make sure you passed models in your config.yaml or on the Spanway Admin UI. - https://docs.spanway.ai/docs/proxy/configs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of DeploymentInfo | Yes | Data |
GET /v1/model/deprecations
List deployed models with a deprecation date
List models with known deprecation/sunset dates, bucketed by urgency.
Reads deprecation_date metadata from model_prices_and_context_window.json
(and any per-deployment model_info.deprecation_date overrides) for the
models configured on this proxy.
What to send: warn_within_days: Window (in days) used to bucket "imminent" models, 30 by default.
What you get back:
A payload with three lists of ModelDeprecationInfo entries:
- `deprecated`: deprecation date is in the past, so these requests may
fail at any time.
- `imminent`: deprecation date is within `warn_within_days` from today.
- `upcoming`: deprecation date is further out.
Example:
curl -X GET 'http://localhost:4000/model/deprecations' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
warn_within_days | query | integer | No |
Example request:
curl -X GET "http://localhost:4000/v1/model/deprecations" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Deployed models with a known deprecation date, bucketed by urgency. | application/json ModelDeprecationResponse |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
deprecated | array of ModelDeprecationInfo | No | Models whose deprecation date has already passed. |
imminent | array of ModelDeprecationInfo | No | Models whose deprecation date is within warn_within_days from today and require immediate migration planning. |
upcoming | array of ModelDeprecationInfo | No | Models with a future deprecation date outside the warn window. |
warn_within_days | integer | Yes | The window (in days) used to bucket 'imminent' models. |
checked_at | string | Yes | UTC timestamp when the deprecation snapshot was generated. |
GET /model/deprecations
List deployed models with a deprecation date
List models with known deprecation/sunset dates, bucketed by urgency.
Reads deprecation_date metadata from model_prices_and_context_window.json
(and any per-deployment model_info.deprecation_date overrides) for the
models configured on this proxy.
What to send: warn_within_days: Window (in days) used to bucket "imminent" models, 30 by default.
What you get back:
A payload with three lists of ModelDeprecationInfo entries:
- `deprecated`: deprecation date is in the past, so these requests may
fail at any time.
- `imminent`: deprecation date is within `warn_within_days` from today.
- `upcoming`: deprecation date is further out.
Example:
curl -X GET 'http://localhost:4000/model/deprecations' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
warn_within_days | query | integer | No |
Example request:
curl -X GET "http://localhost:4000/model/deprecations" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Deployed models with a known deprecation date, bucketed by urgency. | application/json ModelDeprecationResponse |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
deprecated | array of ModelDeprecationInfo | No | Models whose deprecation date has already passed. |
imminent | array of ModelDeprecationInfo | No | Models whose deprecation date is within warn_within_days from today and require immediate migration planning. |
upcoming | array of ModelDeprecationInfo | No | Models with a future deprecation date outside the warn window. |
warn_within_days | integer | Yes | The window (in days) used to bucket 'imminent' models. |
checked_at | string | Yes | UTC timestamp when the deprecation snapshot was generated. |
GET /model_group/info
Describe each model group with combined limits, prices and capabilities
Lists the model groups the calling key may use, one entry per name a client can send as model. Each entry
combines every deployment behind the name: the providers, the context limits, the price per token, the mode
(chat, embedding and so on), the rate limits and what the model supports, including
supported_reasoning_efforts. Agents the key is explicitly allowed to use are listed too, as chat entries
named a2a/<agent name>. Editor and chat clients such as the VS Code extension read it to fill their model
picker. Pass model_group to describe a single name. A gateway with no models answers {"data": []}.
Nothing changes.
curl http://localhost:4000/model_group/info -H "Authorization: Bearer $SPANWAY_API_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_group | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/model_group/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One entry per model group the caller may use, combining every deployment behind the name. | application/json ModelGroupInfoListResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
data | array of ModelGroupInfoProxy | Yes | Data |
POST /reload/model_cost_map
Reload the price map now
Fetch the price list again from SPANWAY_MODEL_COST_MAP_URL (checked against SPANWAY_MODEL_COST_MAP_SHA256 when that is set) and use it at once for every new request. Other gateway instances pick the new prices up on their next check. When the fetch fails the current prices are kept and the call answers 502. The reload is written to the audit log. Proxy admins only.
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/reload/model_cost_map" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The new prices are in use on this instance and published to the others. | application/json ModelCostMapReloadResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Access denied. Admin role required. Current role: internal_user | application/json ErrorDetail |
| 500 | Database connection not available | application/json ErrorDetail |
| 502 | Failed to reload model cost map: the remote price map could not be fetched. Current pricing data was kept. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | What happened, with the number of models priced |
status | string | Yes | success when the new prices are in use |
models_count | integer | Yes | How many models the reloaded price map prices |
timestamp | string | Yes | When this instance loaded the new prices |
source_revision | string or null | No | Revision of the price map file now in use |
etag | string or null | No | ETag of the fetched file, null for the bundled copy |
POST /schedule/model_cost_map_reload
Reload the price map on a schedule
Reload the price map every hours hours on every gateway instance, so new models and price changes arrive without a restart. Sending a new value replaces the old one. The change is written to the audit log. Proxy admins only.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
hours | query | integer | Yes |
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/schedule/model_cost_map_reload?hours=1" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The schedule every gateway instance now follows. | application/json ModelCostMapScheduleResponse |
| 400 | Hours must be greater than 0 | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Access denied. Admin role required. Current role: internal_user | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Failed to schedule model cost map reload: 500: Database connection not available | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | What the schedule is now |
status | string | Yes | success when the schedule was saved |
interval_hours | integer | Yes | Hours between reloads |
timestamp | string | Yes | When the schedule was saved |
DELETE /schedule/model_cost_map_reload
Stop the scheduled price map reload
Turn off the scheduled reload. The prices in use stay as they are until the next manual reload or restart. The change is written to the audit log. Proxy admins only.
Example request:
curl -X DELETE "http://localhost:4000/schedule/model_cost_map_reload" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Access denied. Admin role required. Current role: internal_user | application/json ErrorDetail |
| 500 | Failed to cancel model cost map reload: 500: Database connection not available | application/json ErrorDetail |
GET /schedule/model_cost_map_reload/status
Show the price map reload schedule
Say whether a scheduled reload is on, how often it runs, when it last ran and when it runs next, plus the revision of the price map in use. Proxy admins and admin viewers.
Example request:
curl -X GET "http://localhost:4000/schedule/model_cost_map_reload/status" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Access denied. Admin role required. Current role: internal_user | application/json ErrorDetail |
| 500 | Failed to get model cost map reload status: database query failed | application/json ErrorDetail |
GET /model/cost_map/source
Show where the price map came from
Say whether the prices in use come from the remote price map or the copy bundled in the image, the URL tried, why the remote copy was not used when it was not, when the map was loaded, its revision and how many models it prices. is_env_forced is true when SPANWAY_LOCAL_MODEL_COST_MAP=True keeps the bundled copy. Proxy admins and admin viewers.
Example request:
curl -X GET "http://localhost:4000/model/cost_map/source" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Access denied. Admin role required. Current role: internal_user | application/json ErrorDetail |
| 500 | Failed to get model cost map source info: price map metadata is unavailable | application/json ErrorDetail |
PATCH /model/{model_id}/update
Change some fields of a stored deployment
Change only the fields you send on a deployment stored in the database, and keep every other field as it is.
model_id in the path is the deployment's id from /model/info. The answer is the stored deployment after the
change. A deployment defined in config.yaml answers 400 and an unknown id answers 404. Sending
model_info.blocked pauses or resumes the deployment, which only a proxy admin may do. Every change is written
to the audit log as updated.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_id | path | string | Yes |
Request body (application/json, schema updateDeployment):
| Field | Type | Required | Description |
|---|---|---|---|
model_name | string or null | No | Model Name |
spanway_params | updateSpanwayParams or null | No | |
model_info | ModelInfo or null | No | |
blocked | boolean or null | No | Blocked |
Example request:
curl -X PATCH "http://localhost:4000/model/model_id-123/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spanway_params": {
"rpm": 1000
},
"model_info": {
"description": "Raised limit"
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored deployment after the patch. | application/json Spanway_ProxyModelTable |
| 400 | Model updates only supported for DB-stored models or Cannot edit config-based model. Store model in DB via /model/new first. or Team id=team-support does not exist in db or Credential 'anthropic-prod' not found. Create it via /credentials before attaching it to a model. or spanway_credential_name cannot be an empty string. Send null to detach the stored credential or omit the field to leave it unchanged. | application/json ProxyError |
| 403 | You must be a Spanway Enterprise user to use this feature. If you have a license please set SPANWAY_LICENSE in your env. Get a free 30 day trial key here: https://www.spanway.ai/enterprise#trial. Pricing: https://www.spanway.ai/#pricing or View-only users cannot manage models. or Team ID=team-support does not match the API key's team ID=team-sales, OR you are not the admin for this team. Check /user/info to verify your team admin status. or User does not have permission to make this model call. Your role=internal_user. You can only make model calls if you are a PROXY_ADMIN or if you are a team admin, by specifying a team_id in the model_info. or Only a proxy admin can attach a stored credential (spanway_credential_name) on a model. Your role=internal_user. or Only a proxy admin can set aws_session_tags on a model. Your role=internal_user. or Only proxy admins can change a model's blocked flag. | application/json ProxyError |
| 404 | Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keys | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
model_name | string | Yes | Model Name |
spanway_params | object | Yes | Spanway Params |
model_info | object or null | No | Model Info |
blocked | boolean | No | Blocked |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
POST /model/block
Stop a deployment from serving requests
Take one stored deployment out of routing without deleting it. The router skips a blocked deployment, so this is the quick way to sit out a provider incident and keep the configuration for later. Proxy admins only, and only for deployments stored in the database.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability |
Request body (application/json, schema BlockModelRequest):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
Example request:
curl -X POST "http://localhost:4000/model/block" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_id": "9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The deployment, now blocked. | application/json Spanway_ProxyModelTable |
| 400 | Cannot edit config-based model. Store model in DB via /model/new first. | application/json ProxyError |
| 403 | Only proxy admins can change a model's blocked flag. | application/json ProxyError |
| 404 | Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keys | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
model_name | string | Yes | Model Name |
spanway_params | object | Yes | Spanway Params |
model_info | object or null | No | Model Info |
blocked | boolean | No | Blocked |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
POST /model/unblock
Let a blocked deployment serve requests again
Put a blocked deployment back into routing. Proxy admins only, and only for deployments stored in the database.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
spanway-changed-by | header | string or null | No | The spanway-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability |
Request body (application/json, schema BlockModelRequest):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
Example request:
curl -X POST "http://localhost:4000/model/unblock" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_id": "9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The deployment, now serving again. | application/json Spanway_ProxyModelTable |
| 400 | Cannot edit config-based model. Store model in DB via /model/new first. | application/json ProxyError |
| 403 | Only proxy admins can change a model's blocked flag. | application/json ProxyError |
| 404 | Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keys | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
model_name | string | Yes | Model Name |
spanway_params | object | Yes | Spanway Params |
model_info | object or null | No | Model Info |
blocked | boolean | No | Blocked |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
POST /model/delete
Delete a stored deployment
Remove a deployment that was added at runtime. Send the deployment id in id. Deployments defined in
config.yaml are not in the database and cannot be deleted here. Requires STORE_MODEL_IN_DB=True.
Request body (application/json, schema ModelInfoDelete):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
Example request:
curl -X POST "http://localhost:4000/model/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The deployment is removed from the database and from every gateway instance on its next reload. | application/json ModelDeleteResponse |
| 400 | Model with id=9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found in db | application/json ProxyError |
| 403 | View-only users cannot manage models. or Only a proxy admin can delete a model whose team has been deleted. or User does not have permission to make this model call. Your role=internal_user. You can only make model calls if you are a PROXY_ADMIN or if you are a team admin, by specifying a team_id in the model_info. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | No DB Connected. Here's how to do it - https://docs.spanway.ai/docs/proxy/virtual_keys or Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature. | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
POST /model/new
Add a model deployment without a restart
Store a new deployment in the database so every gateway instance starts serving it on its next config
reload, with no restart. model_name is the public name clients send, spanway_params.model is the
provider model behind it, and the other spanway_params carry the credential (an os.environ/ reference,
a spanway_credential_name or the value itself, which is encrypted at rest) and limits such as rpm.
model_info holds metadata returned by /model/info, such as access_groups and a description.
Requires STORE_MODEL_IN_DB=True. Proxy admins can add any deployment, team admins can add deployments
scoped to their team, and internal users are refused when disable_model_add_for_internal_users is set.
Request body (application/json, schema Deployment):
| Field | Type | Required | Description |
|---|---|---|---|
model_name | string | Yes | Model Name |
spanway_params | Spanway_Params | Yes | Spanway Params with 'model' requirement - used for completions |
model_info | ModelInfo | No | |
blocked | boolean or null | No | Blocked |
Example request:
curl -X POST "http://localhost:4000/model/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_name": "claude-haiku-5-5",
"spanway_params": {
"model": "anthropic/claude-haiku-5-5",
"api_key": "os.environ/ANTHROPIC_API_KEY",
"rpm": 500
},
"model_info": {
"description": "Fast model for classification",
"access_groups": [
"general"
]
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored deployment. model_id is what update, block and delete calls refer to. | application/json Spanway_ProxyModelTable |
| 400 | Team id=team-support does not exist in db or Credential 'anthropic-prod' not found. Create it via /credentials before attaching it to a model. or spanway_credential_name cannot be an empty string. Send null to detach the stored credential or omit the field to leave it unchanged. | application/json ProxyError |
| 403 | Model creation is disabled for internal users by disable_model_add_for_internal_users. or You must be a Spanway Enterprise user to use this feature. If you have a license please set SPANWAY_LICENSE in your env. Get a free 30 day trial key here: https://www.spanway.ai/enterprise#trial. Pricing: https://www.spanway.ai/#pricing or View-only users cannot manage models. or Team ID=team-support does not match the API key's team ID=team-sales, OR you are not the admin for this team. Check /user/info to verify your team admin status. or User does not have permission to make this model call. Your role=internal_user. You can only make model calls if you are a PROXY_ADMIN or if you are a team admin, by specifying a team_id in the model_info. or Only a proxy admin can attach a stored credential (spanway_credential_name) on a model. Your role=internal_user. or Only a proxy admin can set aws_session_tags on a model. Your role=internal_user. or Only proxy admins can set a model's blocked flag. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | No DB Connected. Here's how to do it - https://docs.spanway.ai/docs/proxy/virtual_keys or Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature. | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
model_name | string | Yes | Model Name |
spanway_params | object | Yes | Spanway Params |
model_info | object or null | No | Model Info |
blocked | boolean | No | Blocked |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
POST /model/update
Replace the parameters of a stored deployment
Update a stored deployment, found by model_info.id, with the spanway_params and model_info you
send. Secrets you leave out are kept, and secrets you send are encrypted before they are stored. Deployments
defined in config.yaml cannot be edited here. PATCH /model/{model_id}/update does the same for a
partial change.
Request body (application/json, schema updateDeployment):
| Field | Type | Required | Description |
|---|---|---|---|
model_name | string or null | No | Model Name |
spanway_params | updateSpanwayParams or null | No | |
model_info | ModelInfo or null | No | |
blocked | boolean or null | No | Blocked |
Example request:
curl -X POST "http://localhost:4000/model/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_info": {
"id": "9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8"
},
"spanway_params": {
"rpm": 1000
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored deployment after the update. | application/json Spanway_ProxyModelTable |
| 400 | Can't edit model. Model in config. Store model in db via /model/new. to edit. or model_info.id is required. Send the id of the deployment to update. or spanway_params is required. Send the deployment's spanway_params, or use PATCH /model/{model_id}/update. or Team id=team-support does not exist in db or Credential 'anthropic-prod' not found. Create it via /credentials before attaching it to a model. or spanway_credential_name cannot be an empty string. Send null to detach the stored credential or omit the field to leave it unchanged. | application/json ProxyError |
| 403 | You must be a Spanway Enterprise user to use this feature. If you have a license please set SPANWAY_LICENSE in your env. Get a free 30 day trial key here: https://www.spanway.ai/enterprise#trial. Pricing: https://www.spanway.ai/#pricing or View-only users cannot manage models. or Team ID=team-support does not match the API key's team ID=team-sales, OR you are not the admin for this team. Check /user/info to verify your team admin status. or User does not have permission to make this model call. Your role=internal_user. You can only make model calls if you are a PROXY_ADMIN or if you are a team admin, by specifying a team_id in the model_info. or Only a proxy admin can attach a stored credential (spanway_credential_name) on a model. Your role=internal_user. or Only a proxy admin can set aws_session_tags on a model. Your role=internal_user. | application/json ProxyError |
| 404 | Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy. | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | No DB Connected. Here's how to do it - https://docs.spanway.ai/docs/proxy/virtual_keys | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | Model Id |
model_name | string | Yes | Model Name |
spanway_params | object | Yes | Spanway Params |
model_info | object or null | No | Model Info |
blocked | boolean | No | Blocked |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
POST /model_group/make_public
Choose which model groups the public hub and catalogue list
Replace the list of model groups shown on the AI hub (GET /public/model_hub) and in the public catalogue
(GET /public/catalogue). The list you send is the whole list, so a group left out stops being public.
Nothing is public until an admin calls this or picks models on the AI Hub page. Proxy admins only.
Request body (application/json, schema UpdatePublicModelGroupsRequest):
| Field | Type | Required | Description |
|---|---|---|---|
model_groups | array of string | Yes | List of model group names to make public |
Example request:
curl -X POST "http://localhost:4000/model_group/make_public" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_groups": [
"claude-sonnet-5-5",
"claude-haiku-5-5"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The new public list, written to the stored config and audited. | application/json PublicModelGroupsResponse |
| 403 | Only proxy admins can update public model groups. Your role=internal_user | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature. | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
public_model_groups | array of string | Yes | Public Model Groups |
updated_by | string or null | Yes | Updated By |
POST /model_hub/update_useful_links
Set the useful links shown on the AI hub
Replace the links listed under Useful Links on the AI hub. Each entry maps a display name to a URL and a
display index. Only absolute http:// and https:// URLs are accepted. Proxy admins only.
Request body (application/json, schema UpdateUsefulLinksRequest):
| Field | Type | Required | Description |
|---|---|---|---|
useful_links | object | Yes | Useful Links |
Example request:
curl -X POST "http://localhost:4000/model_hub/update_useful_links" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"useful_links": {
"Internal model guide": {
"url": "https://wiki.example.com/models",
"index": 0
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The saved links, in display order. | application/json UsefulLinksResponse |
| 403 | Only proxy admins can update the AI hub useful links. Your role=internal_user | application/json ProxyError |
| 422 | useful link 'Internal model guide' must be an absolute http:// or https:// URL | application/json ProxyError |
| 500 | Error updating useful links: Database not connected. Please connect a database. | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
useful_links | object | Yes | Useful Links |
updated_by | string or null | Yes | Updated By |
GET /auto_router/classifier/default_prompt
Get the built-in classifier prompt of an auto router
Get the classifier system prompt a router would send, so the dashboard can show it.
The prompt's closing line depends on whether prior conversation turns are quoted to the classifier, its tier bullets are named by the router's tier_labels, and its calibration examples come from the router's classification rubric, so the caller passes all three to get the text that router would actually send rather than a rubric it does not use.
An edited tier set replaces the whole rubric; POST to this path for that prompt, which carries the operator's own instructions and so must not ride in a query string.
What to send:
context_window_size: The router's classifier_context_window_size. Defaults to the built-in default.tier_labels: The router's tier_labels as a JSON object of canonical tier name to display name, e.g.{"SIMPLE": "Cheap"}. Omit or pass an empty object for the default names.- classification_rubric: ClassificationRubric | None - The router's classifier_llm_config.classification_rubric. Omit for the default.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
context_window_size | query | integer | No | |
tier_labels | query | string or null | No | |
classification_rubric | query | ClassificationRubric or null | No |
Example request:
curl -X GET "http://localhost:4000/auto_router/classifier/default_prompt" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The exact system prompt the classifier sends. | application/json AutoRouterClassifierDefaultPromptResponse |
| 400 | tier_labels names a tier that is not one of the complexity tiers | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
system_prompt | string | Yes | System Prompt |
POST /auto_router/classifier/default_prompt
Preview the classifier prompt for an edited tier set
Get the classifier system prompt an edited tier set sends, so the dashboard can show it.
Built by the same function the live classifier uses, so the preview cannot drift from what the router sends. Payload validity beyond a renderable definition stays the dry-run's job.
Request body (application/json, schema AutoRouterClassifierPromptPreviewRequest):
| Field | Type | Required | Description |
|---|---|---|---|
tier_definitions | array of TierDefinition or null | No | Tier Definitions |
tier_labels | object or null | No | Tier Labels |
classification_rubric | ClassificationRubric or null | No | |
context_window_size | integer | No | Context Window Size |
classification_prompt | string or null | No | Classification Prompt |
classification_examples | string or null | No | Classification Examples |
Example request:
curl -X POST "http://localhost:4000/auto_router/classifier/default_prompt" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tier_labels": {
"SIMPLE": "Quick answers",
"COMPLEX": "Deep reasoning"
},
"context_window_size": 3,
"classification_prompt": "Classify by how much reasoning the request needs."
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The exact system prompt the classifier sends. | application/json AutoRouterClassifierDefaultPromptResponse |
| 400 | tier_labels names a tier that is not one of the complexity tiers | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
system_prompt | string | Yes | System Prompt |
POST /access_group/new
Create a model access group
Creates a named set of models, for example production-models, so a key or team can be given every model in the set by naming the group instead of listing each model. The gateway tags each deployment of the named models (or only the deployment ids sent) and reloads its model list. Proxy admins only, and the change is written to the audit log.
Example:
curl -X POST 'http://localhost:4000/access_group/new' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"access_group": "production-models",
"model_names": ["claude-sonnet-5-5", "gpt-5.5"]
}'
Send access_group and either model_names or model_ids. A model name that does not exist answers 400 and a
group name already in use answers 409.
Request body (application/json, schema NewModelGroupRequest):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name, for example production-models |
model_names | array of string or null | No | Model names to include, every deployment of each name is tagged |
model_ids | array of string or null | No | Deployment ids to tag, more precise than model_names |
Example request:
curl -X POST "http://localhost:4000/access_group/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"access_group": "production-models",
"model_names": [
"claude-sonnet-5-5",
"gpt-5.5"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The new access group and how many deployments it tagged | application/json NewModelGroupResponse |
| 400 | A model name does not exist or no model was sent | application/json ErrorDetail |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 409 | An access group with that name already exists | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
model_names | array of string or null | No | The model names that were sent |
model_ids | array of string or null | No | The deployment ids that were sent |
models_updated | integer | Yes | How many deployments now carry the access group |
GET /access_group/list
List model access groups
Lists every model access group with its model names, how many deployments carry it, its shared budget and the spend drawn against that budget. Proxy admins and admin viewers may call it, and nothing changes.
Example:
curl -X GET 'http://localhost:4000/access_group/list' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Example request:
curl -X GET "http://localhost:4000/access_group/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every access group with its models, budget and spend | application/json ListAccessGroupsResponse |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_groups | array of AccessGroupInfo | Yes | Access Groups |
GET /access_group/{access_group}/info
Read one model access group
Reads one model access group with its model names, deployment count, shared budget and spend. Proxy admins and admin viewers may call it, and nothing changes. An unknown group name answers 404.
Example:
curl -X GET 'http://localhost:4000/access_group/production-models/info' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/access_group/access_group-123/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The access group with its models, budget and spend | application/json AccessGroupInfo |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
model_names | array of string | Yes | The model names in the group |
deployment_count | integer | Yes | How many deployments carry the group |
spend | number or null | No | Spend drawn against the group's shared budget, in USD |
budget | AccessGroupBudget or null | No | The shared budget, null when none is set |
PUT /access_group/{access_group}/update
Replace the models of an access group
Replaces the models in an access group. The group is removed from every deployment that carries it, then added to the deployments of the new model_names (or model_ids), and the model list reloads, so keys and teams that name the group get the new set at once. Proxy admins only, and the change is written to the audit log.
Example:
curl -X PUT 'http://localhost:4000/access_group/production-models/update' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model_names": ["claude-sonnet-5-5", "gpt-5.5"]
}'
A model name that does not exist answers 400 and an unknown group name 404.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Request body (application/json, schema UpdateModelGroupRequest):
| Field | Type | Required | Description |
|---|---|---|---|
model_names | array of string or null | No | The new model names, every deployment of each name is tagged |
model_ids | array of string or null | No | The new deployment ids to tag, more precise than model_names |
Example request:
curl -X PUT "http://localhost:4000/access_group/access_group-123/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_names": [
"claude-sonnet-5-5",
"gpt-5.5"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The access group and how many deployments it now tags | application/json NewModelGroupResponse |
| 400 | A model name does not exist or no model was sent | application/json ErrorDetail |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
model_names | array of string or null | No | The model names that were sent |
model_ids | array of string or null | No | The deployment ids that were sent |
models_updated | integer | Yes | How many deployments now carry the access group |
DELETE /access_group/{access_group}/delete
Delete a model access group
Deletes a model access group. It is removed from every deployment that carries it and its shared budget is cleared, so keys and teams that named the group lose those models. The models themselves stay. Proxy admins only, and the change is written to the audit log. An unknown group name answers 404.
Example:
curl -X DELETE 'http://localhost:4000/access_group/production-models/delete' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/access_group/access_group-123/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The access group is gone from every deployment | application/json DeleteModelGroupResponse |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group that was deleted |
models_updated | integer | Yes | How many deployments the access group was removed from |
message | string | Yes | A plain confirmation |
GET /access_group/{access_group}/budget
Read an access group's shared budget
Reads the shared budget of an access group and the spend drawn against it by every key that can reach the group.
budget is null when the group has no budget set. Proxy admins and admin viewers may call it, and nothing
changes. An unknown group name answers 404.
Example:
curl -X GET 'http://localhost:4000/access_group/production-models/budget' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/access_group/access_group-123/budget" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The shared budget and the spend drawn against it | application/json AccessGroupBudgetResponse |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
spend | number | Yes | Shared spend of every key that can reach the group, in USD |
budget | AccessGroupBudget or null | No | The budget, null when none is set |
PUT /access_group/{access_group}/budget
Set an access group's shared budget
Sets or replaces the shared budget of an access group, so the spend of every key that can reach a model in the
group counts against one limit. max_budget makes requests fail once the shared spend passes it, soft_budget
only fires an alert, budget_duration resets the spend on a schedule such as 30d, and budget_id links an
existing budget instead. Sending the same budget twice changes nothing. Proxy admins only, and the change is
written to the audit log.
Example:
curl -X PUT 'http://localhost:4000/access_group/production-models/budget' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"max_budget": 100.0,
"budget_duration": "30d"
}'
Sending no budget field answers 400 and an unknown group name 404.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Request body (application/json, schema AccessGroupBudgetRequest):
| Field | Type | Required | Description |
|---|---|---|---|
budget_id | string or null | No | Link an existing budget instead of creating one |
max_budget | number or null | No | Requests fail once shared spend passes this |
soft_budget | number or null | No | An alert fires when shared spend reaches this |
budget_duration | string or null | No | How often the spend resets, for example 30d |
Example request:
curl -X PUT "http://localhost:4000/access_group/access_group-123/budget" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"max_budget": 100,
"soft_budget": 80,
"budget_duration": "30d"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The stored budget and the current spend | application/json AccessGroupBudgetResponse |
| 400 | A model name does not exist or no model was sent | application/json ErrorDetail |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
spend | number | Yes | Shared spend of every key that can reach the group, in USD |
budget | AccessGroupBudget or null | No | The budget, null when none is set |
DELETE /access_group/{access_group}/budget
Clear an access group's shared budget
Clears the shared budget of an access group and leaves the group and its models in place, so its keys stop
counting against a shared limit. budget_deleted is false when there was nothing to clear. Proxy admins only, and
the change is written to the audit log. An unknown group name answers 404.
Example:
curl -X DELETE 'http://localhost:4000/access_group/production-models/budget' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
access_group | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/access_group/access_group-123/budget" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Whether a budget was cleared | application/json DeleteAccessGroupBudgetResponse |
| 401 | No valid key, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No access group has that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The database is not connected or the change failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_group | string | Yes | The access group name |
budget_deleted | boolean | Yes | False when the group had no budget to clear |
message | string | Yes | A plain confirmation |
POST /auto_router/validate_complexity_router_config
Check an auto router config without saving it
Checks a complexity auto router config the way saving it would, without saving it, so the Add Auto Router form
can show the exact problem while the operator is still typing. Proxy admins may call it for any router; team
admins and members the team lets build routers pass their team_id. Nothing is created, routed, or billed.
Runs the same check every write path runs (the router's own pydantic model), so a form can show the backend's exact verdict while the operator is still editing rather than after a rejected save. Uses the same team opt-in and model-access checks as configuration writes for members. Nothing is created, routed, or billed.
Request body (application/json, schema ComplexityRouterConfigValidationRequest):
| Field | Type | Required | Description |
|---|---|---|---|
complexity_router_config | object | Yes | The complexity router config to check, in the shape /model/new accepts |
team_id | string or null | No | Team the router is being created for. Required for a team admin, who may only validate their own team's routers |
Example request:
curl -X POST "http://localhost:4000/auto_router/validate_complexity_router_config" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"complexity_router_config": {
"tiers": {
"SIMPLE": "claude-haiku-5-5",
"MEDIUM": "claude-sonnet-5-5",
"COMPLEX": "claude-sonnet-5-5",
"REASONING": "claude-opus-5-5"
},
"classifier_type": "heuristic"
},
"team_id": "team-platform"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Whether the config would be accepted, and the exact reason when it would not | application/json ComplexityRouterConfigValidationResponse |
| 400 | team_id names no team | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller is not a proxy admin, or is not an admin or allowed member of team_id | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
valid | boolean | Yes | Whether saving this config would be accepted |
error | string or null | No | Why the config would be rejected, when it would be |
POST /auto_router/availability
Check which auto router options the license still allows
Return, for the auto router configuration in the body, how many Heuristic v2, Capability, Fuse v2, custom tier and rule-based tuning allowances the license has left and whether saving this configuration is allowed. The Add Auto Router form calls it whenever the configuration changes. Proxy admins may check any router; team admins and allowed members pass their team_id and may only check their own saved routers. Nothing is saved.
Request body (application/json, schema AutoRouterAvailabilityRequest):
| Field | Type | Required | Description |
|---|---|---|---|
team_id | string or null | No | Team the router is for; required for team admins |
saved_model_id | string or null | No | Id of the saved auto router being edited, so its own allowance is not counted |
complexity_router_config | object or null | No | The auto router config the form currently holds |
Example request:
curl -X POST "http://localhost:4000/auto_router/availability" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"team_id": "team-platform",
"complexity_router_config": {
"tiers": {
"SIMPLE": "claude-haiku-5-5",
"MEDIUM": "claude-sonnet-5-5",
"COMPLEX": "claude-sonnet-5-5",
"REASONING": "claude-opus-5-5"
},
"classifier_type": "heuristic_v2"
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The license allowances left and whether this config may be saved | application/json AutoRouterAvailabilityResponse |
| 400 | team_id names no team | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller is not a proxy admin, or is not an admin or allowed member of team_id | application/json ErrorDetail |
| 404 | saved_model_id names no saved auto router | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 503 | The model list has not loaded yet, so allowances cannot be counted | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
allowances | array of AutoRouterAllowance | Yes | One entry per licensed auto router option |
error | string or null | No | Why saving this config is refused, when it is |
POST /auto_router/test_routing
Preview which model an auto router would pick
Route a single request through a complexity-router config and report where it landed. Proxy admins may test
any config; team admins and members the team lets build routers pass their team_id.
Answers "which model would this request get?" for a config that only exists in a form,
so an auto router can be checked before it is created. The request is classified by the
same pre-routing hook a live request runs, over the same messages, system prompt and tool
definitions, then dropped: nothing is sent to the model it routed to, and no auto router is
created. A heuristic config therefore spends nothing, while an llm classifier or semantic
keyword matching bills its classifier/embedding call to the calling key, like Test Connection
does.
Send messages to classify a real turn, with system and tools beside it when the surface
carries them top level, as Anthropic /v1/messages does. prompt is the single-ask shorthand and
routes as one user turn with nothing around it.
Example Request:
{
"messages": [
{"role": "system", "content": "You are a database migration assistant"},
{"role": "user", "content": "the index is not unique"},
{"role": "assistant", "content": "Then two workers can both insert. Add a unique index"},
{"role": "user", "content": "ok do it"}
],
"tools": [{"type": "function", "function": {"name": "Bash", "description": "Run a command"}}],
"complexity_router_config": {
"tiers": {"SIMPLE": ["claude-haiku-5-5"], "REASONING": ["claude-opus-5-5"]},
"classifier_type": "heuristic"
}
}
Request body (application/json, schema AutoRouterRoutingTestRequest):
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string or null | No | A single ask to route, as an end user would send it. Mutually exclusive with messages |
messages | array of object or null | No | The full message list to route, exactly as the serving path would receive it. Mutually exclusive with prompt |
system | string or array of object or null | No | The top-level system prompt an Anthropic /v1/messages body carries beside its messages |
tools | array of object or null | No | The tool definitions the request advertises, which decide whether the plan-mode floor applies |
complexity_router_config | RequestComplexityRouterConfig | Yes | The complexity router config to route against, in the shape /model/new accepts |
saved_model_id | string or null | No | Test this saved deployment's server-side configuration instead of the supplied config and default model |
default_model | string or null | No | Model to route to when no tier resolves, i.e. complexity_router_default_model |
router_name | string | No | Name reported as the router in the routing decision. Display only |
team_id | string or null | No | Team the router is being created for. Required for a team admin, who may only test their own team's routers |
Example request:
curl -X POST "http://localhost:4000/auto_router/test_routing" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "system",
"content": "You are a database migration assistant"
},
{
"role": "user",
"content": "the index is not unique"
},
{
"role": "assistant",
"content": "Then two workers can both insert. Add a unique index"
},
{
"role": "user",
"content": "ok do it"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "Bash",
"description": "Run a command"
}
}
],
"complexity_router_config": {
"tiers": {
"SIMPLE": "claude-haiku-5-5",
"MEDIUM": "claude-sonnet-5-5",
"COMPLEX": "claude-sonnet-5-5",
"REASONING": "claude-opus-5-5"
},
"classifier_type": "heuristic"
},
"team_id": "team-platform"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The model the router picked and the decision record a live request would log | application/json AutoRouterRoutingTestResponse |
| 400 | The prompt could not be routed, the key is over budget, or the saved deployment is not a complexity router | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller is not a proxy admin, or is not an admin or allowed member of team_id | application/json ErrorDetail |
| 404 | saved_model_id names no saved auto router | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
routed_model | string | Yes | The model group the router picked |
routed_model_configured | boolean | Yes | Whether routed_model is a model group available to the caller, scoped to team_id when given. Never confirms models the caller could not use |
routing_decision | StandardLoggingRoutingDecision | Yes | The decision record this request would have written to its log row |