Skip to main content

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.

MethodPathSummary
GET/modelsList the models this key can call
GET/v1/modelsList 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/infoPage through every deployment with pricing, provider and access
GET/v1/model/infoList every deployment with its parameters, pricing and capabilities
GET/model/infoList every deployment with its parameters, pricing and capabilities
GET/v1/model/deprecationsList deployed models with a deprecation date
GET/model/deprecationsList deployed models with a deprecation date
GET/model_group/infoDescribe each model group with combined limits, prices and capabilities
POST/reload/model_cost_mapReload the price map now
POST/schedule/model_cost_map_reloadReload the price map on a schedule
DELETE/schedule/model_cost_map_reloadStop the scheduled price map reload
GET/schedule/model_cost_map_reload/statusShow the price map reload schedule
GET/model/cost_map/sourceShow where the price map came from
PATCH/model/{model_id}/updateChange some fields of a stored deployment
POST/model/blockStop a deployment from serving requests
POST/model/unblockLet a blocked deployment serve requests again
POST/model/deleteDelete a stored deployment
POST/model/newAdd a model deployment without a restart
POST/model/updateReplace the parameters of a stored deployment
POST/model_group/make_publicChoose which model groups the public hub and catalogue list
POST/model_hub/update_useful_linksSet the useful links shown on the AI hub
GET/auto_router/classifier/default_promptGet the built-in classifier prompt of an auto router
POST/auto_router/classifier/default_promptPreview the classifier prompt for an edited tier set
POST/access_group/newCreate a model access group
GET/access_group/listList model access groups
GET/access_group/{access_group}/infoRead one model access group
PUT/access_group/{access_group}/updateReplace the models of an access group
DELETE/access_group/{access_group}/deleteDelete a model access group
GET/access_group/{access_group}/budgetRead an access group's shared budget
PUT/access_group/{access_group}/budgetSet an access group's shared budget
DELETE/access_group/{access_group}/budgetClear an access group's shared budget
POST/auto_router/validate_complexity_router_configCheck an auto router config without saving it
POST/auto_router/availabilityCheck which auto router options the license still allows
POST/auto_router/test_routingPreview 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's model_info.service_tiers as 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: true to apply this to every caller without the query parameter. Requires background_health_checks: true in general_settings, 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). Models expanded from wildcard routes (e.g. openai/*) are not filtered, and nothing is hidden when allowed_fails_policy is configured (cooldown remains the sole exclusion mechanism). Hiding is presentation-only: a hidden model can still be called directly.

Parameters:

NameInTypeRequiredDescription
return_wildcard_routesqueryboolean or nullNo
team_idquerystring or nullNo
include_model_access_groupsqueryboolean or nullNo
only_model_access_groupsqueryboolean or nullNo
include_metadataqueryboolean or nullNo
fallback_typequerystring or nullNo
scopequerystring or nullNo
healthy_onlyqueryboolean or nullNo
client_versionquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The public model names this key may call, in the OpenAI listing shape.application/json ModelListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
object"list"YesObject
dataarray of ModelInfoResponseYesData

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's model_info.service_tiers as 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: true to apply this to every caller without the query parameter. Requires background_health_checks: true in general_settings, 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). Models expanded from wildcard routes (e.g. openai/*) are not filtered, and nothing is hidden when allowed_fails_policy is configured (cooldown remains the sole exclusion mechanism). Hiding is presentation-only: a hidden model can still be called directly.

Parameters:

NameInTypeRequiredDescription
return_wildcard_routesqueryboolean or nullNo
team_idquerystring or nullNo
include_model_access_groupsqueryboolean or nullNo
only_model_access_groupsqueryboolean or nullNo
include_metadataqueryboolean or nullNo
fallback_typequerystring or nullNo
scopequerystring or nullNo
healthy_onlyqueryboolean or nullNo
client_versionquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/models" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The public model names this key may call, in the OpenAI listing shape.application/json ModelListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
object"list"YesObject
dataarray of ModelInfoResponseYesData

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:

NameInTypeRequiredDescription
model_idpathstringYes
team_idquerystring or nullNo
healthy_onlyqueryboolean or nullNo

Example request:

curl -X GET "http://localhost:4000/models/model_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The model, when the key may call it.application/json ModelInfoResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
404Model not found or not accessible to your API keyapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
object"model"YesObject
createdintegerYesCreated
owned_bystringYesOwned By
modestringNoMode
max_input_tokensintegerNoMax Input Tokens
max_output_tokensintegerNoMax Output Tokens
metadataModelInfoMetadataNo

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:

NameInTypeRequiredDescription
model_idpathstringYes
team_idquerystring or nullNo
healthy_onlyqueryboolean or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/models/model_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The model, when the key may call it.application/json ModelInfoResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
404Model not found or not accessible to your API keyapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
idstringYesId
object"model"YesObject
createdintegerYesCreated
owned_bystringYesOwned By
modestringNoMode
max_input_tokensintegerNoMax Input Tokens
max_output_tokensintegerNoMax Output Tokens
metadataModelInfoMetadataNo

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:

NameInTypeRequiredDescription
modelquerystring or nullNoSpecify the model name (optional)
user_models_onlyqueryboolean or nullNoOnly return models added by this user
include_team_modelsqueryboolean or nullNoReturn all models across all teams user is in.
debugqueryboolean or nullNo
pagequeryintegerNoPage number
sizequeryintegerNoPage size
searchquerystring or nullNoSearch model names (case-insensitive partial match)
modelIdquerystring or nullNoSearch for a specific model by its unique ID
teamIdquerystring or nullNoFilter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids
sortByquerystring or nullNoField to sort by. Options: model_name, created_at, updated_at, costs, status
sortOrderquerystring or nullNoSort order. Options: asc, desc
exclude_auto_routersqueryboolean or nullNoOmit 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_groupquerystring or nullNoOnly return deployments whose model_info.access_groups contains this access group
wildcard_onlyqueryboolean or nullNoOnly 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:

StatusDescriptionBody
200One page of deployments with their enriched model_info and the paging totals.application/json ModelInfoPageResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500LLM 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/configsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray of DeploymentInfoYesData
total_countintegerYesTotal Count
current_pageintegerYesCurrent Page
total_pagesintegerYesTotal 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:

NameInTypeRequiredDescription
spanway_model_idquerystring or nullNo
include_team_modelsqueryboolean or nullNoWhen true, filter to deployments the caller can use via direct access or team membership.
teamIdquerystring or nullNoFilter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids
healthy_onlyqueryboolean or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/model/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Every deployment the caller may see, with secrets removed and pricing, mode and limits filled in.application/json ModelInfoListResponse
400Model id = 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on spanway proxyapplication/json ProxyError
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500LLM 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/configsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray of DeploymentInfoYesData

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:

NameInTypeRequiredDescription
spanway_model_idquerystring or nullNo
include_team_modelsqueryboolean or nullNoWhen true, filter to deployments the caller can use via direct access or team membership.
teamIdquerystring or nullNoFilter models by team ID. Returns models with direct_access=True or teamId in access_via_team_ids
healthy_onlyqueryboolean or nullNo

Example request:

curl -X GET "http://localhost:4000/model/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Every deployment the caller may see, with secrets removed and pricing, mode and limits filled in.application/json ModelInfoListResponse
400Model id = 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on spanway proxyapplication/json ProxyError
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500LLM 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/configsapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
dataarray of DeploymentInfoYesData

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:

NameInTypeRequiredDescription
warn_within_daysqueryintegerNo

Example request:

curl -X GET "http://localhost:4000/v1/model/deprecations" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Deployed models with a known deprecation date, bucketed by urgency.application/json ModelDeprecationResponse
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
deprecatedarray of ModelDeprecationInfoNoModels whose deprecation date has already passed.
imminentarray of ModelDeprecationInfoNoModels whose deprecation date is within warn_within_days from today and require immediate migration planning.
upcomingarray of ModelDeprecationInfoNoModels with a future deprecation date outside the warn window.
warn_within_daysintegerYesThe window (in days) used to bucket 'imminent' models.
checked_atstringYesUTC 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:

NameInTypeRequiredDescription
warn_within_daysqueryintegerNo

Example request:

curl -X GET "http://localhost:4000/model/deprecations" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Deployed models with a known deprecation date, bucketed by urgency.application/json ModelDeprecationResponse
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
deprecatedarray of ModelDeprecationInfoNoModels whose deprecation date has already passed.
imminentarray of ModelDeprecationInfoNoModels whose deprecation date is within warn_within_days from today and require immediate migration planning.
upcomingarray of ModelDeprecationInfoNoModels with a future deprecation date outside the warn window.
warn_within_daysintegerYesThe window (in days) used to bucket 'imminent' models.
checked_atstringYesUTC 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:

NameInTypeRequiredDescription
model_groupquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/model_group/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200One entry per model group the caller may use, combining every deployment behind the name.application/json ModelGroupInfoListResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
dataarray of ModelGroupInfoProxyYesData

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:

StatusDescriptionBody
200The new prices are in use on this instance and published to the others.application/json ModelCostMapReloadResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Access denied. Admin role required. Current role: internal_userapplication/json ErrorDetail
500Database connection not availableapplication/json ErrorDetail
502Failed to reload model cost map: the remote price map could not be fetched. Current pricing data was kept.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesWhat happened, with the number of models priced
statusstringYessuccess when the new prices are in use
models_countintegerYesHow many models the reloaded price map prices
timestampstringYesWhen this instance loaded the new prices
source_revisionstring or nullNoRevision of the price map file now in use
etagstring or nullNoETag 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:

NameInTypeRequiredDescription
hoursqueryintegerYes

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:

StatusDescriptionBody
200The schedule every gateway instance now follows.application/json ModelCostMapScheduleResponse
400Hours must be greater than 0application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Access denied. Admin role required. Current role: internal_userapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Failed to schedule model cost map reload: 500: Database connection not availableapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesWhat the schedule is now
statusstringYessuccess when the schedule was saved
interval_hoursintegerYesHours between reloads
timestampstringYesWhen 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:

StatusDescriptionBody
200Successful Responseapplication/json any
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Access denied. Admin role required. Current role: internal_userapplication/json ErrorDetail
500Failed to cancel model cost map reload: 500: Database connection not availableapplication/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:

StatusDescriptionBody
200Successful Responseapplication/json any
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Access denied. Admin role required. Current role: internal_userapplication/json ErrorDetail
500Failed to get model cost map reload status: database query failedapplication/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:

StatusDescriptionBody
200Successful Responseapplication/json any
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Access denied. Admin role required. Current role: internal_userapplication/json ErrorDetail
500Failed to get model cost map source info: price map metadata is unavailableapplication/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:

NameInTypeRequiredDescription
model_idpathstringYes

Request body (application/json, schema updateDeployment):

FieldTypeRequiredDescription
model_namestring or nullNoModel Name
spanway_paramsupdateSpanwayParams or nullNo
model_infoModelInfo or nullNo
blockedboolean or nullNoBlocked

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:

StatusDescriptionBody
200The stored deployment after the patch.application/json Spanway_ProxyModelTable
400Model 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
403You 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
404Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy.application/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500DB 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_keysapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
model_idstringYesModel Id
model_namestringYesModel Name
spanway_paramsobjectYesSpanway Params
model_infoobject or nullNoModel Info
blockedbooleanNoBlocked
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated 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:

NameInTypeRequiredDescription
spanway-changed-byheaderstring or nullNoThe 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):

FieldTypeRequiredDescription
model_idstringYesModel 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:

StatusDescriptionBody
200The deployment, now blocked.application/json Spanway_ProxyModelTable
400Cannot edit config-based model. Store model in DB via /model/new first.application/json ProxyError
403Only proxy admins can change a model's blocked flag.application/json ProxyError
404Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy.application/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500DB 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_keysapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
model_idstringYesModel Id
model_namestringYesModel Name
spanway_paramsobjectYesSpanway Params
model_infoobject or nullNoModel Info
blockedbooleanNoBlocked
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated 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:

NameInTypeRequiredDescription
spanway-changed-byheaderstring or nullNoThe 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):

FieldTypeRequiredDescription
model_idstringYesModel 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:

StatusDescriptionBody
200The deployment, now serving again.application/json Spanway_ProxyModelTable
400Cannot edit config-based model. Store model in DB via /model/new first.application/json ProxyError
403Only proxy admins can change a model's blocked flag.application/json ProxyError
404Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy.application/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500DB 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_keysapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
model_idstringYesModel Id
model_namestringYesModel Name
spanway_paramsobjectYesSpanway Params
model_infoobject or nullNoModel Info
blockedbooleanNoBlocked
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated 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):

FieldTypeRequiredDescription
idstringYesId

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:

StatusDescriptionBody
200The deployment is removed from the database and from every gateway instance on its next reload.application/json ModelDeleteResponse
400Model with id=9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found in dbapplication/json ProxyError
403View-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
422Validation Errorapplication/json HTTPValidationError
500No 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):

FieldTypeRequiredDescription
messagestringYesMessage

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):

FieldTypeRequiredDescription
model_namestringYesModel Name
spanway_paramsSpanway_ParamsYesSpanway Params with 'model' requirement - used for completions
model_infoModelInfoNo
blockedboolean or nullNoBlocked

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:

StatusDescriptionBody
200The stored deployment. model_id is what update, block and delete calls refer to.application/json Spanway_ProxyModelTable
400Team 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
403Model 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
422Validation Errorapplication/json HTTPValidationError
500No 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):

FieldTypeRequiredDescription
model_idstringYesModel Id
model_namestringYesModel Name
spanway_paramsobjectYesSpanway Params
model_infoobject or nullNoModel Info
blockedbooleanNoBlocked
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated 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):

FieldTypeRequiredDescription
model_namestring or nullNoModel Name
spanway_paramsupdateSpanwayParams or nullNo
model_infoModelInfo or nullNo
blockedboolean or nullNoBlocked

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:

StatusDescriptionBody
200The stored deployment after the update.application/json Spanway_ProxyModelTable
400Can'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
403You 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
404Model 9f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8 not found on proxy.application/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500No DB Connected. Here's how to do it - https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
model_idstringYesModel Id
model_namestringYesModel Name
spanway_paramsobjectYesSpanway Params
model_infoobject or nullNoModel Info
blockedbooleanNoBlocked
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated 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):

FieldTypeRequiredDescription
model_groupsarray of stringYesList 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:

StatusDescriptionBody
200The new public list, written to the stored config and audited.application/json PublicModelGroupsResponse
403Only proxy admins can update public model groups. Your role=internal_userapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500Set 'STORE_MODEL_IN_DB='True' in your env to enable this feature.application/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
public_model_groupsarray of stringYesPublic Model Groups
updated_bystring or nullYesUpdated 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):

FieldTypeRequiredDescription
useful_linksobjectYesUseful 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:

StatusDescriptionBody
200The saved links, in display order.application/json UsefulLinksResponse
403Only proxy admins can update the AI hub useful links. Your role=internal_userapplication/json ProxyError
422useful link 'Internal model guide' must be an absolute http:// or https:// URLapplication/json ProxyError
500Error updating useful links: Database not connected. Please connect a database.application/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
useful_linksobjectYesUseful Links
updated_bystring or nullYesUpdated 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:

NameInTypeRequiredDescription
context_window_sizequeryintegerNo
tier_labelsquerystring or nullNo
classification_rubricqueryClassificationRubric or nullNo

Example request:

curl -X GET "http://localhost:4000/auto_router/classifier/default_prompt" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The exact system prompt the classifier sends.application/json AutoRouterClassifierDefaultPromptResponse
400tier_labels names a tier that is not one of the complexity tiersapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
system_promptstringYesSystem 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):

FieldTypeRequiredDescription
tier_definitionsarray of TierDefinition or nullNoTier Definitions
tier_labelsobject or nullNoTier Labels
classification_rubricClassificationRubric or nullNo
context_window_sizeintegerNoContext Window Size
classification_promptstring or nullNoClassification Prompt
classification_examplesstring or nullNoClassification 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:

StatusDescriptionBody
200The exact system prompt the classifier sends.application/json AutoRouterClassifierDefaultPromptResponse
400tier_labels names a tier that is not one of the complexity tiersapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
system_promptstringYesSystem 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):

FieldTypeRequiredDescription
access_groupstringYesThe access group name, for example production-models
model_namesarray of string or nullNoModel names to include, every deployment of each name is tagged
model_idsarray of string or nullNoDeployment 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:

StatusDescriptionBody
200The new access group and how many deployments it taggedapplication/json NewModelGroupResponse
400A model name does not exist or no model was sentapplication/json ErrorDetail
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
409An access group with that name already existsapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
model_namesarray of string or nullNoThe model names that were sent
model_idsarray of string or nullNoThe deployment ids that were sent
models_updatedintegerYesHow 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:

StatusDescriptionBody
200Every access group with its models, budget and spendapplication/json ListAccessGroupsResponse
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupsarray of AccessGroupInfoYesAccess 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Example request:

curl -X GET "http://localhost:4000/access_group/access_group-123/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The access group with its models, budget and spendapplication/json AccessGroupInfo
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
model_namesarray of stringYesThe model names in the group
deployment_countintegerYesHow many deployments carry the group
spendnumber or nullNoSpend drawn against the group's shared budget, in USD
budgetAccessGroupBudget or nullNoThe 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Request body (application/json, schema UpdateModelGroupRequest):

FieldTypeRequiredDescription
model_namesarray of string or nullNoThe new model names, every deployment of each name is tagged
model_idsarray of string or nullNoThe 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:

StatusDescriptionBody
200The access group and how many deployments it now tagsapplication/json NewModelGroupResponse
400A model name does not exist or no model was sentapplication/json ErrorDetail
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
model_namesarray of string or nullNoThe model names that were sent
model_idsarray of string or nullNoThe deployment ids that were sent
models_updatedintegerYesHow 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Example request:

curl -X DELETE "http://localhost:4000/access_group/access_group-123/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The access group is gone from every deploymentapplication/json DeleteModelGroupResponse
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group that was deleted
models_updatedintegerYesHow many deployments the access group was removed from
messagestringYesA 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Example request:

curl -X GET "http://localhost:4000/access_group/access_group-123/budget" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The shared budget and the spend drawn against itapplication/json AccessGroupBudgetResponse
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
spendnumberYesShared spend of every key that can reach the group, in USD
budgetAccessGroupBudget or nullNoThe 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Request body (application/json, schema AccessGroupBudgetRequest):

FieldTypeRequiredDescription
budget_idstring or nullNoLink an existing budget instead of creating one
max_budgetnumber or nullNoRequests fail once shared spend passes this
soft_budgetnumber or nullNoAn alert fires when shared spend reaches this
budget_durationstring or nullNoHow 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:

StatusDescriptionBody
200The stored budget and the current spendapplication/json AccessGroupBudgetResponse
400A model name does not exist or no model was sentapplication/json ErrorDetail
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
spendnumberYesShared spend of every key that can reach the group, in USD
budgetAccessGroupBudget or nullNoThe 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:

NameInTypeRequiredDescription
access_grouppathstringYes

Example request:

curl -X DELETE "http://localhost:4000/access_group/access_group-123/budget" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Whether a budget was clearedapplication/json DeleteAccessGroupBudgetResponse
401No valid key, or the key is not a proxy admin keyapplication/json ProxyError
404No access group has that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The database is not connected or the change failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
access_groupstringYesThe access group name
budget_deletedbooleanYesFalse when the group had no budget to clear
messagestringYesA 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):

FieldTypeRequiredDescription
complexity_router_configobjectYesThe complexity router config to check, in the shape /model/new accepts
team_idstring or nullNoTeam 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:

StatusDescriptionBody
200Whether the config would be accepted, and the exact reason when it would notapplication/json ComplexityRouterConfigValidationResponse
400team_id names no teamapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller is not a proxy admin, or is not an admin or allowed member of team_idapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
validbooleanYesWhether saving this config would be accepted
errorstring or nullNoWhy 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):

FieldTypeRequiredDescription
team_idstring or nullNoTeam the router is for; required for team admins
saved_model_idstring or nullNoId of the saved auto router being edited, so its own allowance is not counted
complexity_router_configobject or nullNoThe 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:

StatusDescriptionBody
200The license allowances left and whether this config may be savedapplication/json AutoRouterAvailabilityResponse
400team_id names no teamapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller is not a proxy admin, or is not an admin or allowed member of team_idapplication/json ErrorDetail
404saved_model_id names no saved auto routerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
503The model list has not loaded yet, so allowances cannot be countedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
allowancesarray of AutoRouterAllowanceYesOne entry per licensed auto router option
errorstring or nullNoWhy 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):

FieldTypeRequiredDescription
promptstring or nullNoA single ask to route, as an end user would send it. Mutually exclusive with messages
messagesarray of object or nullNoThe full message list to route, exactly as the serving path would receive it. Mutually exclusive with prompt
systemstring or array of object or nullNoThe top-level system prompt an Anthropic /v1/messages body carries beside its messages
toolsarray of object or nullNoThe tool definitions the request advertises, which decide whether the plan-mode floor applies
complexity_router_configRequestComplexityRouterConfigYesThe complexity router config to route against, in the shape /model/new accepts
saved_model_idstring or nullNoTest this saved deployment's server-side configuration instead of the supplied config and default model
default_modelstring or nullNoModel to route to when no tier resolves, i.e. complexity_router_default_model
router_namestringNoName reported as the router in the routing decision. Display only
team_idstring or nullNoTeam 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:

StatusDescriptionBody
200The model the router picked and the decision record a live request would logapplication/json AutoRouterRoutingTestResponse
400The prompt could not be routed, the key is over budget, or the saved deployment is not a complexity routerapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller is not a proxy admin, or is not an admin or allowed member of team_idapplication/json ErrorDetail
404saved_model_id names no saved auto routerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
routed_modelstringYesThe model group the router picked
routed_model_configuredbooleanYesWhether 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_decisionStandardLoggingRoutingDecisionYesThe decision record this request would have written to its log row