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.
| Method | Path | Summary |
|---|---|---|
| GET | /health/liveness | Liveness probe |
| OPTIONS | /health/liveness | Allowed methods of the liveness probe |
| GET | /health/liveliness | Liveness probe |
| OPTIONS | /health/liveliness | Allowed methods of the liveness probe |
| GET | /test | Echo the route, deprecated |
| GET | /health/services | Send a test event to a logging or alerting integration |
| GET | /health | Check every deployment with a real request |
| GET | /health/history | Page through stored health checks |
| GET | /health/latest | Newest stored health check per model |
| GET | /health/shared-status | State of shared background health checks |
| GET | /health/license | License status without the key |
| GET | /active/callbacks | Loaded callbacks and alerting |
| GET | /settings | Loaded callbacks and alerting |
| GET | /health/readiness | Readiness probe |
| OPTIONS | /health/readiness | Allowed methods of the readiness probe |
| GET | /health/readiness/details | Readiness with cache, version and callback details |
| GET | /health/backlog | Requests in flight on this worker |
| GET | /health/drain | Drain this worker before it stops |
| POST | /health/test_connection | Test 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:
| Status | Description | Body |
|---|---|---|
| 200 | The worker process is up | application/json string |
| 503 | The worker is draining and must leave the load balancer rotation | application/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.
Example request:
curl -X OPTIONS "http://localhost:4000/health/liveness"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | No 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:
| Status | Description | Body |
|---|---|---|
| 200 | The worker process is up | application/json string |
| 503 | The worker is draining and must leave the load balancer rotation | application/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.
Example request:
curl -X OPTIONS "http://localhost:4000/health/liveliness"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | No 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:
| Status | Description | Body |
|---|---|---|
| 200 | The route the gateway saw | application/json RouteEcho |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
route | string | Yes | Route |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
service | query | enum: "slack_budget_alerts", "email", "langfuse", "langfuse_otel", "slack", "ms_teams", "openmeter", "webhook", ... or string | Yes | Specify 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:
| Status | Description | Body |
|---|---|---|
| 200 | The integration accepted the test event, or a mock request was sent through the callback to check | application/json ServiceHealth |
| 400 | Service must be in list. Service=jira not in ['datadog', 'langfuse', 'slack'] | application/json ProxyError |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | Only 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 |
| 500 | MS 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):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | success, healthy or unhealthy |
message | string | Yes | Message |
alert_types | array of string or null | No | Slack 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | query | string or null | No | Specify the model name (optional) |
model_id | query | string or null | No | Specify the model ID (optional) |
Example request:
curl -X GET "http://localhost:4000/health" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Each deployment the caller may see, healthy or not | application/json HealthCheckReport |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key may not call the model or deployment it named | application/json ErrorDetail |
| 404 | No deployment carries the model_id asked for | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway has no model list yet | application/json ErrorDetail |
| 503 | A single model or deployment was asked for and none of its deployments is healthy | application/json HealthCheckReport |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
healthy_endpoints | array of object | Yes | Deployments that answered, secrets removed |
unhealthy_endpoints | array of object | Yes | Deployments that failed, each with its error |
healthy_count | integer | Yes | Healthy Count |
unhealthy_count | integer | Yes | Unhealthy 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model | query | string or null | No | Filter by specific model name |
status_filter | query | string or null | No | Filter by status (healthy/unhealthy) |
limit | query | integer | No | Number of records to return |
offset | query | integer | No | Number of records to skip |
Example request:
curl -X GET "http://localhost:4000/health/history" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Stored checks newest first | application/json HealthCheckHistory |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, or the stored checks could not be read | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
health_checks | array of object | Yes | Stored checks newest first |
total_records | integer | Yes | Rows in this page, not the total. Page with offset until fewer than limit rows come back |
limit | integer | Yes | Limit |
offset | integer | Yes | Offset |
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:
| Status | Description | Body |
|---|---|---|
| 200 | One row per model | application/json LatestHealthChecks |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 500 | The gateway runs without a database, or the stored checks could not be read | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
latest_health_checks | object | Yes | The newest stored check per deployment, keyed by model id, or by model name when it has no id |
total_models | integer | Yes | Total 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:
| Status | Description | Body |
|---|---|---|
| 200 | Whether sharing is on, whether Redis answers and which instance holds the lock | application/json SharedHealthCheckStatus |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 500 | Redis did not answer | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
shared_health_check_enabled | boolean | Yes | Shared Health Check Enabled |
redis_available | boolean or null | No | Present when sharing is on but Redis is missing |
message | string or null | No | Why no shared state is available |
status | object or null | No | Lock 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:
| Status | Description | Body |
|---|---|---|
| 200 | Whether a license is active and what it grants | application/json LicenseStatus |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
has_license | boolean | Yes | Has License |
license_type | string | Yes | enterprise with an active license, starter without one |
expiration_date | string or null | Yes | Expiration Date |
allowed_features | array of string | Yes | Feature names the license grants, * for every feature |
limits | LicenseLimits | Yes |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The callbacks and alerting the gateway loaded | application/json ActiveCallbacks |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alerting | string | Yes | The alerting setting from the config, as text, for example ['slack'] |
spanway.callbacks | array of string | Yes | Integrations that log both successes and failures |
spanway.input_callback | array of string | Yes | Integrations that see each request before it is sent |
spanway.failure_callback | array of string | Yes | Integrations that log failed requests |
spanway.success_callback | array of string | Yes | Integrations that log successful requests |
spanway._async_success_callback | array of string | Yes | Success loggers that run in the background |
spanway._async_failure_callback | array of string | Yes | Failure loggers that run in the background |
spanway._async_input_callback | array of string | Yes | Request loggers that run in the background |
all_spanway_callbacks | array of string | Yes | Every list above combined |
num_callbacks | integer | Yes | How many entries all_spanway_callbacks has |
num_alerting | integer | Yes | How many alerting integrations are loaded |
spanway.request_timeout | number | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | The callbacks and alerting the gateway loaded | application/json ActiveCallbacks |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alerting | string | Yes | The alerting setting from the config, as text, for example ['slack'] |
spanway.callbacks | array of string | Yes | Integrations that log both successes and failures |
spanway.input_callback | array of string | Yes | Integrations that see each request before it is sent |
spanway.failure_callback | array of string | Yes | Integrations that log failed requests |
spanway.success_callback | array of string | Yes | Integrations that log successful requests |
spanway._async_success_callback | array of string | Yes | Success loggers that run in the background |
spanway._async_failure_callback | array of string | Yes | Failure loggers that run in the background |
spanway._async_input_callback | array of string | Yes | Request loggers that run in the background |
all_spanway_callbacks | array of string | Yes | Every list above combined |
num_callbacks | integer | Yes | How many entries all_spanway_callbacks has |
num_alerting | integer | Yes | How many alerting integrations are loaded |
spanway.request_timeout | number | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | The worker can take traffic. A coordination_redis value of error is reported but still answers 200 | application/json ReadinessStatus |
| 503 | The 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 true | application/json ReadinessStatus |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | healthy, unhealthy when the database is down and the answer is 503, or shutting_down |
db | string or null | No | connected, disconnected, stalled or Not connected |
airgapped | boolean or null | No | Whether SPANWAY_AIRGAPPED is in effect |
coordination_redis | enum: "connected", "not_configured", "error" or null | No | Shared 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.
Example request:
curl -X OPTIONS "http://localhost:4000/health/readiness"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | No 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:
| Status | Description | Body |
|---|---|---|
| 200 | The readiness body with the fields an operator needs when debugging | application/json object |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 503 | The 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 stalled | application/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:
| Status | Description | Body |
|---|---|---|
| 200 | The admission control counters of the worker that answered | application/json HealthBacklog |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
in_flight_requests | integer | Yes | Requests this worker is handling right now |
admitted_requests | integer | Yes | Requests admission control let in |
queued_requests | integer | Yes | Requests waiting for a slot |
rejected_requests | integer | Yes | Requests 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:
| Status | Description | Body |
|---|---|---|
| 200 | Every in-flight request finished or the timeout passed | application/json DrainResult |
| 401 | X-Drain-Token is missing or wrong, or no drain token is configured | application/json ErrorDetail |
| 404 | general_settings.enable_drain_endpoint is not true | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | drained |
drained_requests | integer | Yes | Requests 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_NAMEare 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):
| Field | Type | Required | Description |
|---|---|---|---|
mode | enum: "chat", "completion", "embedding", "audio_speech", "audio_transcription", "image_generation", "image_edit", "video_generation", ... or null | No | The 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_params | object | No | Provider parameters for the test call (model, api_base, credentials) |
model_info | object | No | Model 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:
| Status | Description | Body |
|---|---|---|
| 200 | The provider answered, or the error it returned | application/json ModelConnectionTest |
| 400 | The body named an environment variable | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key may not add or call this model, the same rule that guards adding a model | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The check itself failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | success or error |
result | object | Yes | The provider answer or the error, secrets removed |