Skip to content

Inference monitoring

OpenGateLLM records usage for each model-forward API request (chat completions, embeddings, OCR, rerank, audio transcriptions). This helps you analyze consumption over time, identify patterns, and support reporting.

Usage is recorded in the PostgreSQL usage table, for successful requests only: a failed request consumed nothing. GET /v1/usage (and the Playground Usage page) reads from this table.

When the Langfuse dependency is configured, every model-forward request is also traced in Langfuse, failures included.

Sensitive information such as the prompt or response content is not included in the logs.

The usage table contains the following information:

  • user ID
  • router ID
  • provider ID
  • number of input tokens
  • number of output tokens
  • environmental footprint (see the dedicated documentation here)
  • cost (see the dedicated documentation here)

User can see their usage in the Usage page of the Playground.

Usage playground page

In addition to the usage data stored in PostgreSQL, OpenGateLLM can expose real-time inference metrics (request rate, request duration, time to first token, token consumption and output generation speed) in Prometheus format on the /metrics endpoint.

Ready-to-use Grafana dashboards built on these metrics are available in the grafana/ folder of the repository. See the Prometheus documentation for the list of exposed metrics, the dashboards and the configuration.

Prometheus documentation

OpenGateLLM provides a health check endpoint to monitor the health of the models. This endpoint is available at /health/models and returns a JSON response with the health status of the models.

{
"data": [
{
"id": "model_name",
"status": "green" | "yellow" | "red"
}
]
}

The endpoint requires authentication. It only returns models (routers) the calling user is allowed to access.

Each model is assigned one of three statuses:

Status Meaning
green The provider responds and queue depth is within normal bounds.
yellow The provider responds but is under moderate load.
red The provider is unreachable, metrics are unavailable, or queue depth indicates severe degradation.

The default status is green. Status only escalates during the check; it is never downgraded back to green once a worse condition is detected.

Health is evaluated per model (router). A model can have several providers; the model status is the worst status among its providers (red > yellow > green).

For each provider attached to the model, OpenGateLLM probes the inference backend:

  1. Metrics-capable providers (vLLM and on-prem Mistral): query the provider /metrics endpoint (Prometheus format) and read vllm:num_requests_waiting and vllm:num_requests_running for the configured model name.
  2. Other providers: /metrics is not supported yet. OpenGateLLM falls back to /v1/models instead. If that endpoint returns a successful response, the provider is considered green. If it fails, the provider is red.

In all cases, a failed or unparseable metrics response sets the provider to red.

Queue-depth thresholds were calibrated against load tests targeting the following service conditions:

  • Time to first token (TTFT) < 5 seconds
  • Throughput > 30 tokens/second

Under load, these targets correlate with the yellow and red boundaries below:

Status Observed degradation (load tests)
yellow p95 TTFT reaches 5 seconds, or throughput drops below 31 tokens/second
red TTFT reaches 40 seconds, or throughput drops below 27 tokens/second

The health check does not measure TTFT or throughput directly. It uses waiting and running request counts from provider metrics as proxies for these conditions.

Condition Status
/metrics unavailable or invalid red
num_requests_waiting > 0 yellow
num_requests_running > 20 red