Skip to main content

Health API

This page documents the 19 gateway endpoints tagged health 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/health/livenessLiveness probe
OPTIONS/health/livenessAllowed methods of the liveness probe
GET/health/livelinessLiveness probe
OPTIONS/health/livelinessAllowed methods of the liveness probe
GET/testEcho the route, deprecated
GET/health/servicesSend a test event to a logging or alerting integration
GET/healthCheck every deployment with a real request
GET/health/historyPage through stored health checks
GET/health/latestNewest stored health check per model
GET/health/shared-statusState of shared background health checks
GET/health/licenseLicense status without the key
GET/active/callbacksLoaded callbacks and alerting
GET/settingsLoaded callbacks and alerting
GET/health/readinessReadiness probe
OPTIONS/health/readinessAllowed methods of the readiness probe
GET/health/readiness/detailsReadiness with cache, version and callback details
GET/health/backlogRequests in flight on this worker
GET/health/drainDrain this worker before it stops
POST/health/test_connectionTest one model with the parameters you send

Endpoints​

GET /health/liveness​

Liveness probe

Unprotected endpoint for checking if worker is alive.

Returns 503 once graceful shutdown has begun so Kubernetes stops counting the draining pod as live and terminates it on schedule.

Example request:

curl -X GET "http://localhost:4000/health/liveness"

Responses:

StatusDescriptionBody
200The worker process is upapplication/json string
503The worker is draining and must leave the load balancer rotationapplication/json ShuttingDown

OPTIONS /health/liveness​

Allowed methods of the liveness probe

Answer a CORS preflight for the liveness probe with the methods it allows, GET and OPTIONS, and no body.

Docs

Example request:

curl -X OPTIONS "http://localhost:4000/health/liveness"

Responses:

StatusDescriptionBody
200No body, the allowed methods are in the Allow header

GET /health/liveliness​

Liveness probe

Unprotected endpoint for checking if worker is alive.

Returns 503 once graceful shutdown has begun so Kubernetes stops counting the draining pod as live and terminates it on schedule.

Example request:

curl -X GET "http://localhost:4000/health/liveliness"

Responses:

StatusDescriptionBody
200The worker process is upapplication/json string
503The worker is draining and must leave the load balancer rotationapplication/json ShuttingDown

OPTIONS /health/liveliness​

Allowed methods of the liveness probe

Answer a CORS preflight for the liveness probe with the methods it allows, GET and OPTIONS, and no body.

Docs

Example request:

curl -X OPTIONS "http://localhost:4000/health/liveliness"

Responses:

StatusDescriptionBody
200No body, the allowed methods are in the Allow header

GET /test​

Echo the route, deprecated

[DEPRECATED] use /health/liveliness instead.

Answers with the route the gateway saw for this request, which shows that the gateway is up and that the key was accepted.

Example request:

curl -X GET "http://localhost:4000/test"

Responses:

StatusDescriptionBody
200The route the gateway sawapplication/json RouteEcho
401No valid key or Admin UI session was presentedapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
routestringYesRoute

GET /health/services​

Send a test event to a logging or alerting integration

Sends one test event to a logging or alerting integration (for example Datadog, Langfuse or a webhook) so an operator can confirm the gateway can reach it with the configured credentials. Any key may call it for integrations that only log; tests that send a real alert, email or ping (Slack, Microsoft Teams, email, webhook, New Relic, PointFive) are proxy admin only. The Slack test also posts the weekly and monthly spend reports. The email test sends through the SMTP alerting path and needs email in general_settings.alerting. The integration receives one test event; nothing on the gateway changes.

Example:

curl -L -X GET 'http://0.0.0.0:4000/health/services?service=datadog' -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

Parameters:

NameInTypeRequiredDescription
servicequeryenum: "slack_budget_alerts", "email", "langfuse", "langfuse_otel", "slack", "ms_teams", "openmeter", "webhook", ... or stringYesSpecify the service being hit.

Example request:

curl -X GET "http://localhost:4000/health/services?service=slack_budget_alerts" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The integration accepted the test event, or a mock request was sent through the callback to checkapplication/json ServiceHealth
400Service must be in list. Service=jira not in ['datadog', 'langfuse', 'slack']application/json ProxyError
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Only proxy admins can trigger the webhook test alert. or Only proxy admins can trigger the New Relic test event. or Only proxy admins can trigger the PointFive liveness ping. or Only proxy admins can trigger the slack test alert.application/json ProxyError
422"otel" is not set up on this gateway. Add it to spanway_settings.success_callback to test it. or "slack" not in proxy config: general_settings. Unable to test this. or MS_TEAMS_WEBHOOK_URL not set. Unable to test this. or WEBHOOK_URL not set. Unable to test this.application/json ProxyError
500MS Teams webhook returned status 403: Forbidden or The test email could not be sent. The gateway log has the cause.application/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
statusstringYessuccess, healthy or unhealthy
messagestringYesMessage
alert_typesarray of string or nullNoSlack test only: the alert types it sent

GET /health​

Check every deployment with a real request

To check that the gateway is up, use /health/liveliness.

See https://docs.spanway.ai/docs/proxy/health for every health route.

Check the health of all the endpoints in config.yaml

To run health checks in the background, add this to config.yaml:

general_settings:
**... other settings**
background_health_checks: True

else, the health checks will be run on models when /health is called. With background checks on, this route answers from the last background cycle and calls no provider.

Pass model or model_id to check one model or one deployment. Keys that are not proxy admins get the result without api_base and api_version, and the Spanway-Health-Field-Notice header names the fields that were removed. A warnings list appears when some deployments the key may see carry no model_info.id.

To skip deployments that set model_info.disable_background_health_check: true on GET /health as well as in the background loop, set general_settings.health_check_skip_disabled_background_models: true.

Parameters:

NameInTypeRequiredDescription
modelquerystring or nullNoSpecify the model name (optional)
model_idquerystring or nullNoSpecify the model ID (optional)

Example request:

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

Responses:

StatusDescriptionBody
200Each deployment the caller may see, healthy or notapplication/json HealthCheckReport
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key may not call the model or deployment it namedapplication/json ErrorDetail
404No deployment carries the model_id asked forapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway has no model list yetapplication/json ErrorDetail
503A single model or deployment was asked for and none of its deployments is healthyapplication/json HealthCheckReport

Response fields (200):

FieldTypeRequiredDescription
healthy_endpointsarray of objectYesDeployments that answered, secrets removed
unhealthy_endpointsarray of objectYesDeployments that failed, each with its error
healthy_countintegerYesHealthy Count
unhealthy_countintegerYesUnhealthy Count

GET /health/history​

Page through stored health checks

Pages through the stored results of the background health checks, newest first, so an operator can see when a model started failing and how slow it was. Filter by model or status. Proxy admins and admin viewers only. Nothing changes.

Parameters:

NameInTypeRequiredDescription
modelquerystring or nullNoFilter by specific model name
status_filterquerystring or nullNoFilter by status (healthy/unhealthy)
limitqueryintegerNoNumber of records to return
offsetqueryintegerNoNumber of records to skip

Example request:

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

Responses:

StatusDescriptionBody
200Stored checks newest firstapplication/json HealthCheckHistory
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, or the stored checks could not be readapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
health_checksarray of objectYesStored checks newest first
total_recordsintegerYesRows in this page, not the total. Page with offset until fewer than limit rows come back
limitintegerYesLimit
offsetintegerYesOffset

GET /health/latest​

Newest stored health check per model

Shows the newest stored background health check for every model, for the Health page of the Admin UI. Proxy admins and admin viewers only. Nothing changes.

Example request:

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

Responses:

StatusDescriptionBody
200One row per modelapplication/json LatestHealthChecks
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
500The gateway runs without a database, or the stored checks could not be readapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
latest_health_checksobjectYesThe newest stored check per deployment, keyed by model id, or by model name when it has no id
total_modelsintegerYesTotal Models

GET /health/shared-status​

State of shared background health checks

Shows whether gateway replicas share one set of background health checks through Redis, so only one replica probes each model: whether Redis answers, which replica holds the lock and whether a cached result exists. Proxy admins and admin viewers only. Nothing changes.

Example request:

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

Responses:

StatusDescriptionBody
200Whether sharing is on, whether Redis answers and which instance holds the lockapplication/json SharedHealthCheckStatus
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
500Redis did not answerapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
shared_health_check_enabledbooleanYesShared Health Check Enabled
redis_availableboolean or nullNoPresent when sharing is on but Redis is missing
messagestring or nullNoWhy no shared state is available
statusobject or nullNoLock holder and cache state from Redis

GET /health/license​

License status without the key

Shows whether a Spanway license is active, its type, expiry date, features and limits, without ever returning the license key itself. Any key may call it; the Admin UI uses it to show which features are on. Nothing changes.

Example request:

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

Responses:

StatusDescriptionBody
200Whether a license is active and what it grantsapplication/json LicenseStatus
401No valid key or Admin UI session was presentedapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
has_licensebooleanYesHas License
license_typestringYesenterprise with an active license, starter without one
expiration_datestring or nullYesExpiration Date
allowed_featuresarray of stringYesFeature names the license grants, * for every feature
limitsLicenseLimitsYes

GET /active/callbacks​

Loaded callbacks and alerting

List the logging and alerting integrations the gateway has loaded, so you can check that a config change took effect. Each list holds the integration names, and the counts and the request timeout follow them.

Example request:

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

Responses:

StatusDescriptionBody
200The callbacks and alerting the gateway loadedapplication/json ActiveCallbacks
401No valid key or Admin UI session was presentedapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
alertingstringYesThe alerting setting from the config, as text, for example ['slack']
spanway.callbacksarray of stringYesIntegrations that log both successes and failures
spanway.input_callbackarray of stringYesIntegrations that see each request before it is sent
spanway.failure_callbackarray of stringYesIntegrations that log failed requests
spanway.success_callbackarray of stringYesIntegrations that log successful requests
spanway._async_success_callbackarray of stringYesSuccess loggers that run in the background
spanway._async_failure_callbackarray of stringYesFailure loggers that run in the background
spanway._async_input_callbackarray of stringYesRequest loggers that run in the background
all_spanway_callbacksarray of stringYesEvery list above combined
num_callbacksintegerYesHow many entries all_spanway_callbacks has
num_alertingintegerYesHow many alerting integrations are loaded
spanway.request_timeoutnumberYesThe request timeout in seconds the gateway applies

GET /settings​

Loaded callbacks and alerting

List the logging and alerting integrations the gateway has loaded, so you can check that a config change took effect. Each list holds the integration names, and the counts and the request timeout follow them.

Example request:

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

Responses:

StatusDescriptionBody
200The callbacks and alerting the gateway loadedapplication/json ActiveCallbacks
401No valid key or Admin UI session was presentedapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
alertingstringYesThe alerting setting from the config, as text, for example ['slack']
spanway.callbacksarray of stringYesIntegrations that log both successes and failures
spanway.input_callbackarray of stringYesIntegrations that see each request before it is sent
spanway.failure_callbackarray of stringYesIntegrations that log failed requests
spanway.success_callbackarray of stringYesIntegrations that log successful requests
spanway._async_success_callbackarray of stringYesSuccess loggers that run in the background
spanway._async_failure_callbackarray of stringYesFailure loggers that run in the background
spanway._async_input_callbackarray of stringYesRequest loggers that run in the background
all_spanway_callbacksarray of stringYesEvery list above combined
num_callbacksintegerYesHow many entries all_spanway_callbacks has
num_alertingintegerYesHow many alerting integrations are loaded
spanway.request_timeoutnumberYesThe request timeout in seconds the gateway applies

GET /health/readiness​

Readiness probe

Public readiness probe. Returns a low-detail payload safe to expose to unauthenticated load balancers: status plus db so orchestrators and external probes can distinguish "healthy" from "DB unreachable" without a credential, and airgapped so operators can confirm SPANWAY_AIRGAPPED took effect. Admins can opt into the legacy detailed payload with general_settings.allow_public_health_readiness_details.

Example request:

curl -X GET "http://localhost:4000/health/readiness"

Responses:

StatusDescriptionBody
200The worker can take traffic. A coordination_redis value of error is reported but still answers 200application/json ReadinessStatus
503The worker is draining, or its database is disconnected or stalled. The database case still answers 200 while general_settings.allow_requests_on_db_unavailable is trueapplication/json ReadinessStatus

Response fields (200):

FieldTypeRequiredDescription
statusstringYeshealthy, unhealthy when the database is down and the answer is 503, or shutting_down
dbstring or nullNoconnected, disconnected, stalled or Not connected
airgappedboolean or nullNoWhether SPANWAY_AIRGAPPED is in effect
coordination_redisenum: "connected", "not_configured", "error" or nullNoShared Redis: connected, not_configured or error. It never changes the HTTP status

OPTIONS /health/readiness​

Allowed methods of the readiness probe

Answer a CORS preflight for the readiness probe with the methods it allows, GET and OPTIONS, and no body.

Docs

Example request:

curl -X OPTIONS "http://localhost:4000/health/readiness"

Responses:

StatusDescriptionBody
200No body, the allowed methods are in the Allow header

GET /health/readiness/details​

Readiness with cache, version and callback details

Shows the readiness answer plus the details an operator needs when debugging a deployment: database and cache state, the gateway version, loaded logging integrations and log level. Needs a key, unlike the public /health/readiness, because these details help an attacker. Nothing changes.

Example request:

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

Responses:

StatusDescriptionBody
200The readiness body with the fields an operator needs when debuggingapplication/json object
401No valid key or Admin UI session was presentedapplication/json ProxyError
503The details could not be read. A disconnected or stalled database also answers 503, with the details body, status unhealthy and db set to disconnected or stalledapplication/json ErrorDetail

GET /health/backlog​

Requests in flight on this worker

How busy the worker that answered is. in_flight_requests counts every HTTP request it is handling now, and a high value means new requests wait for the event loop before the gateway starts timing them. admitted_requests, queued_requests and rejected_requests are the admission control counters: requests holding a slot, requests waiting for one, and requests refused with 503 since the worker started. The three admission counters stay 0 while admission control is off, which is the default.

Example request:

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

Responses:

StatusDescriptionBody
200The admission control counters of the worker that answeredapplication/json HealthBacklog
401No valid key or Admin UI session was presentedapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
in_flight_requestsintegerYesRequests this worker is handling right now
admitted_requestsintegerYesRequests admission control let in
queued_requestsintegerYesRequests waiting for a slot
rejected_requestsintegerYesRequests refused with 503 since the worker started

GET /health/drain​

Drain this worker before it stops

Graceful-drain probe for Kubernetes preStop hooks.

Disabled by default and returns 404 unless general_settings sets enable_drain_endpoint: true. Calling it flips a process-wide shutting-down flag, so a successful call permanently takes the worker out of rotation until the pod restarts.

Because the kubelet calls preStop hooks without proxy credentials, the endpoint does not require user_api_key_auth. To prevent any pod-reachable caller from triggering shutdown, it needs general_settings.drain_endpoint_token (or the DRAIN_ENDPOINT_TOKEN env var) and the same value on the X-Drain-Token header from the preStop hook. Without a configured token every call is refused. Calls without the header (or with a wrong value) get a 401 and have no side effect, and the SIGTERM handler still drains the worker.

When enabled, it marks the worker as shutting down (so /health/readiness and /health/liveliness immediately start returning 503, removing the pod from service) and blocks until the in-flight request counter drains to zero or GRACEFUL_SHUTDOWN_TIMEOUT elapses. Unlike a fixed sleep, this returns as soon as real in-flight work is done.

Wire it up as:

lifecycle:
preStop:
httpGet:
path: /health/drain
port: 4000
httpHeaders:
- name: X-Drain-Token
value: <same value as drain_endpoint_token>

Example request:

curl -X GET "http://localhost:4000/health/drain"

Responses:

StatusDescriptionBody
200Every in-flight request finished or the timeout passedapplication/json DrainResult
401X-Drain-Token is missing or wrong, or no drain token is configuredapplication/json ErrorDetail
404general_settings.enable_drain_endpoint is not trueapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
statusstringYesdrained
drained_requestsintegerYesRequests that finished while the worker waited

POST /health/test_connection​

Test one model with the parameters you send

Sends one small real request to a model with the parameters in the body, so an admin can check credentials and the provider address before saving a model. Proxy admins may call it, and team admins for their own team's models; the provider bills the test request. Nothing is saved.

Test a direct connection to a specific model.

This endpoint allows you to verify if your proxy can successfully connect to a specific model. It's useful for troubleshooting model connectivity issues without going through the full proxy routing.

Example:

**If model is configured in your config file, you only need to specify the model name:**
curl -X POST 'http://localhost:4000/health/test_connection' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"spanway_params": {
"model": "gpt-5.6"
},
"mode": "chat"
}'

**The endpoint will automatically use api_key, api_base, etc. from your config file**

**You can also test with a credential stored on the Credentials page:**
curl -X POST 'http://localhost:4000/health/test_connection' \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"spanway_params": {
"model": "azure/gpt-4o",
"spanway_credential_name": "azure-prod",
"api_version": "2024-10-21"
},
"mode": "chat"
}'

Note:

  • If the model is configured in your config file, credentials (api_key, api_base, etc.) will be automatically loaded from the config (with resolved environment variables).
  • A request naming a stored credential (spanway_credential_name) that the configuration does not name is probed with that credential instead, and inherits no credentials from the configuration its model string happened to match.
  • You can override specific params by including them in the request.
  • Values written as os.environ/VARIABLE_NAME are refused with a 400, so a request can never read the gateway's environment. Credentials come from the stored model or a stored credential instead.

What you get back: The result of the check, with either the model's answer or the error the provider returned.

Request body (application/json, schema Body_test_model_connection_health_test_connection_post):

FieldTypeRequiredDescription
modeenum: "chat", "completion", "embedding", "audio_speech", "audio_transcription", "image_generation", "image_edit", "video_generation", ... or nullNoThe mode to test the model with. If not provided, resolved the way /health does: the deployment's model_info.mode (only while the request tests the deployment's own model), then the mode the provider requires for that mo
spanway_paramsobjectNoProvider parameters for the test call (model, api_base, credentials)
model_infoobjectNoModel info for the health check

Example request:

curl -X POST "http://localhost:4000/health/test_connection" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spanway_params": {
"model": "gpt-5.5"
},
"mode": "chat"
}'

Responses:

StatusDescriptionBody
200The provider answered, or the error it returnedapplication/json ModelConnectionTest
400The body named an environment variableapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key may not add or call this model, the same rule that guards adding a modelapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The check itself failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
statusstringYessuccess or error
resultobjectYesThe provider answer or the error, secrets removed