OpenAI-Compatible API Health Check: Endpoints, Probes and Scripts (2026)
Why an OpenAI-compatible API has no standard health endpoint
The OpenAI API specification defines /v1/chat/completions, /v1/models and friends, but no /health route. So "health check an OpenAI-compatible API" means different things depending on what sits behind the URL:
- Self-hosted inference servers (vLLM, llama.cpp, SGLang, Ollama) add their own health routes next to the OpenAI ones.
- Gateways such as the LiteLLM proxy expose liveness, readiness and per-model health.
- Hosted APIs and relays (OpenAI, DeepSeek, OpenRouter, most API relays) expose no health route at all. You check them by calling the API itself.
This page covers all three, then gives a script you can drop into cron or an uptime monitor. Server behaviour is taken from each project's docs and source, checked on November 24, 2026: the vLLM server routes and auth middleware, the llama.cpp server README, SGLang's native API, Ollama's API reference and LiteLLM's health docs.
Three levels of "healthy"
A single 200 can mean very different things. Decide which level you need before you pick an endpoint:
|
Level |
Question it answers |
Typical check |
Costs tokens? |
|---|---|---|---|
|
Liveness |
Is the process up? |
Server's |
No |
|
Readiness |
Is the model loaded and can the server accept requests? |
|
No |
|
End-to-end |
Can my key get my model to generate, within my latency budget? |
|
A few tokens |
Load balancers and Kubernetes probes want the first two: cheap, frequent, no tokens. Alerting on "users cannot get answers" needs the third, because a server can be alive and ready while your key is out of balance or the upstream provider is down.
Built-in health endpoints by server
|
Server |
Endpoint |
What a 200 means |
Notes |
|---|---|---|---|
|
vLLM |
|
Engine is running |
Returns 503 if the engine has died. The |
|
llama.cpp server |
|
Model loaded, |
Returns 503 with "Loading model" while loading. Public, no API key check. |
|
SGLang |
|
Up / accepting requests / can generate one token |
|
|
Ollama |
|
Server is up ( |
|
|
LiteLLM proxy |
|
Process up / ready, database reachable |
No LLM calls. |
|
Hosted APIs and relays |
None |
(not applicable) |
Use |
For LiteLLM, turn on background_health_checks: true in general_settings so /health serves cached results instead of calling every model on each request; health_check_interval defaults to 300 seconds.
Check 1: list models
curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" \
https://api.example.com/v1/models \
-H "Authorization: Bearer $API_KEY"A 200 proves three things: the host resolves, the base URL path is right, and the key is accepted. It is fast and does not consume tokens.
It does not prove the model can generate. Many gateways answer /v1/models from their own configuration without contacting the upstream provider, so the list can look healthy while every completion fails. If /v1/models returns 404, fix the URL first; see OpenAI-compatible base URL: what to set.
Check 2: a one-token completion
curl -s https://api.example.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"messages": [{"role": "user", "content": "ping"}],
"max_tokens": 1,
"temperature": 0
}'Expect a 200 with finish_reason of length (the model was cut off after one token, which is what you asked for). This is the only check that exercises the whole path: key, balance, routing, the upstream provider and the model.
Two things to watch:
- Reasoning models. With thinking on, one token may be spent on reasoning and
contentcomes back empty. Disable thinking for the probe where the provider allows it (for example DeepSeek's{"thinking": {"type": "disabled"}}; see our DeepSeek API base URL guide), or judge success by the status code andusagerather than bycontent. - Parameter names. Some newer models reject
max_tokensand wantmax_completion_tokens. If the probe gets a 400 mentioning it, switch the field.
At one input message and one output token, a probe every minute costs very little, but it is not zero, and it counts toward rate limits.
A monitoring script
This Python script runs both checks, measures latency and exits non-zero on failure, so cron, a CI job or an uptime monitor can alert on it:
import os, sys, time, json, urllib.request, urllib.error
BASE = os.environ.get("BASE_URL", "https://api.example.com/v1").rstrip("/")
KEY = os.environ["API_KEY"]
MODEL = os.environ.get("MODEL", "your-model-id")
MAX_SECONDS = float(os.environ.get("MAX_SECONDS", "10"))
def call(path, body=None):
req = urllib.request.Request(
BASE + path,
data=None if body is None else json.dumps(body).encode(),
headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"},
method="GET" if body is None else "POST",
)
start = time.monotonic()
try:
with urllib.request.urlopen(req, timeout=MAX_SECONDS) as r:
return r.status, time.monotonic() - start, json.loads(r.read() or b"{}")
except urllib.error.HTTPError as e:
return e.code, time.monotonic() - start, {}
except Exception as e:
return 0, time.monotonic() - start, {"error": str(e)}
status, secs, _ = call("/models")
print(f"models: {status} in {secs:.2f}s")
if status != 200:
sys.exit(2)
status, secs, body = call("/chat/completions", {
"model": MODEL,
"messages": [{"role": "user", "content": "ping"}],
"max_tokens": 1,
"temperature": 0,
})
print(f"completion: {status} in {secs:.2f}s usage={body.get('usage')}")
if status != 200:
sys.exit(3)
if secs > MAX_SECONDS:
sys.exit(4)Run it from where your users' traffic originates (the same region and network path as your app), not only from your laptop. For what to measure beyond a single round trip, see LLM API latency.
Probes for self-hosted servers
For Kubernetes, point liveness and readiness at the server's own routes, never at a completion:
# vLLM container
livenessProbe:
httpGet: { path: /health, port: 8000 }
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet: { path: /health, port: 8000 }
initialDelaySeconds: 60 # model loading can take minutes
periodSeconds: 10For llama.cpp, the same /health route doubles as a readiness signal because it returns 503 until the model is loaded. For SGLang, use /health for liveness and /ready for readiness. For the LiteLLM proxy on port 4000, use /health/liveliness and /health/readiness. Give large models a generous initial delay; killing a pod that is still loading weights is a common restart loop.
Reading the result
|
Result |
What it usually means |
Mark the endpoint as |
|---|---|---|
|
200 on both checks, latency in budget |
Healthy |
Up |
|
200 but slow |
Upstream congestion, cold start, or a long queue |
Degraded |
|
401 / 403 |
Key revoked, wrong key, or a region or permission block |
Down (for this key) |
|
402 or a balance error |
Account out of funds |
Down; alert billing, not engineering |
|
404 |
Wrong base URL, or the model ID no longer exists |
Down; fix configuration |
|
429 |
Rate limit, possibly caused by the probe itself |
Degraded; slow the probe |
|
500 / 502 / 503 / 529 |
Server or upstream overloaded or failing |
Down if it persists over several probes |
|
Timeout / connection error |
Network, DNS, or the server is not listening |
Down |
Alert on a run of failures (for example three in a row), not on one, and keep the end-to-end probe interval long enough that it never becomes a meaningful share of your rate limit. If you route through a gateway, check both the gateway's own health and one end-to-end request per critical model; our LLM API gateway guide covers where the gateway can hide upstream failures.
FAQ
How do I health check an OpenAI-compatible API?
Call GET /v1/models with your key to confirm the URL and key, then send a chat completion with max_tokens: 1 to confirm the model can generate. Self-hosted servers also expose their own /health routes for cheap liveness checks.
Does vLLM have a health endpoint?
Yes. GET /health returns 200 while the engine is running and 503 if it has died. It is not covered by the --api-key check, so probes do not need a key.
Is GET /v1/models enough as a health check?
No. It confirms the host, path and key, but many gateways answer it from configuration without contacting the model. Only a real completion proves the model can respond.
Does a health check cost tokens?
Server routes such as /health do not. A one-token completion costs a few tokens per run, and LiteLLM's /health sends a real request to each deployment unless background health checks are enabled.
How often should I run an end-to-end probe?
Often enough to catch an outage within your tolerance, commonly every one to five minutes, and alert only after several consecutive failures. More frequent probes add cost and count toward rate limits.
The short version
Use the server's own routes (/health, /ready, /health/liveliness) for load balancers and Kubernetes, because they are free and fast. Use GET /v1/models plus a one-token completion for real monitoring, because only that proves your key can get your model to answer. Hosted APIs and relays only offer the second option, so build it in from the start.