Guide · API operations

LLM API observability: what to log, measure and alert on

LLM API observability starts with a safe request record: request ID, model, latency, token usage, cost, status code, retries and fallback. These fields explain what users experienced without retaining prompt payloads; logs, metrics, traces and alerts then connect one failed request to the reliability and cost of the whole workload.

LLM observabilityRequest logsMetricsAlerts

Reviewed by OpenLux Engineering Team · Last verified

Create an API key Read the docs

Abstract orange glass sculpture illustrating LLM API observability on OpenLux
LLM API observability + OpenLux — one key, one endpoint, one bill.

What do LLM logs, metrics and traces each answer?

Use all three when the workload is important, but start with a stable request record. A dashboard without an investigation path produces alerts no one can resolve.

SignalQuestion it answersTypical fieldsMain risk
LogWhat happened to this request?Request ID, model, status, retry, latency, usage, cost, error classPrompt or response payloads can expose sensitive data
MetricIs the system behaving differently over time?Success rate, p50/p95 latency, TTFT, 429 rate, token rate, costAggregates hide which model or tenant caused the change
TraceWhere did a multi-step workflow spend time or fail?Spans for retrieval, tool calls, LLM requests, retries and final responseIncomplete propagation produces disconnected spans

How we evaluated this

We reviewed OpenTelemetry's generative-AI semantic conventions, the public documentation for Langfuse, Helicone, Datadog LLM Observability and Portkey, Requesty's observability guides and OpenLux's own request-log and usage documentation on 8 November 2026.

Tool capabilities and retention terms change. This page compares operational roles rather than claiming hands-on tests or presenting a universal price for every observability platform.

LLM API observability checklist

Instrument the fields that let an engineer explain user impact, model behavior and spend.

  • Generate a request ID and keep it through retries, fallbacks and tool calls.
  • Record application, environment, API-key label or tenant without storing the key itself.
  • Record requested model, returned model, upstream provider and route or fallback reason.
  • Measure total latency and time to first token separately.
  • Record input, output and cached tokens plus the final billed cost where available.
  • Classify 401, 402, 429 and 5xx errors before deciding whether to retry.
  • Capture retries, attempts and accepted-task outcome so aggregate cost remains interpretable.
  • Keep prompt and response bodies out of default logs unless a reviewed diagnostic mode requires them.

Set it up in four steps

1

Define one request record

Create a structured schema shared by client, gateway and application logs. Use the same request ID and field names across every service.

2

Publish three core metrics

Start with request success, p95 time to completion and cost per accepted task, segmented by model and application.

3

Add traces to workflows

Instrument retrieval, tool calls and each model request as spans. Propagate the trace context through retries and fallback paths.

4

Alert only on user-impacting change

Tie each alert to an owner and a first diagnostic step. Route errors, latency, spend and traffic anomalies to the team that can act.

What is LLM API observability?

LLM API observability is the ability to explain the quality, latency, reliability and cost of model-backed requests from telemetry. It combines structured request logs, aggregate metrics and traces across retrieval, tools and model calls.

Traditional HTTP monitoring is necessary but insufficient. A request can return 200 while producing invalid JSON, selecting the wrong model, leaking PII or costing ten times the budget. Observability must include task outcomes and model identity without collecting sensitive payloads by default.

What should you log for every LLM request?

At minimum, log a request ID, timestamp, application, environment, key or project label, requested model, returned model, provider, status code, error class, total latency, time to first token, input and output tokens, cached tokens and billed cost. Add route, retry and fallback fields when the gateway or application uses them.

Treat prompt and response bodies as a separate decision from metadata. A safe default records enough to investigate without storing customer content. Any opt-in diagnostic capture needs redaction, short retention, access control and a clear deletion process.

Which LLM metrics matter most?

Start with success rate, p50 and p95 latency, time to first token and 429 and 5xx rates. Add tokens per request, retries per accepted request, fallback rate and cost per accepted task. These metrics reveal both user experience and the operational work hidden behind a successful response.

Average latency is not enough. Streaming products feel time to first token, batch jobs feel completion time and agents reveal failures across multiple spans. Segment every metric by model, provider, application and tenant where volume permits.

What should a trace include for agents and RAG?

A useful trace starts at the user request and includes retrieval queries, document IDs or hashed references, tool calls, each model request, retries and the final response. Spans should share one trace ID and identify the model and provider used at each inference step.

Do not put full document text or tool arguments in traces by default. Record counts, durations, status and safe identifiers instead. For sensitive workflows, validate that OpenTelemetry context survives SDK wrappers, streams and asynchronous tool execution.

Which dashboards do you need?

Use three time horizons. A five-minute view helps operators confirm whether an incident is active. A 24-hour view exposes bursts, retries and fallback changes. A 30-day view supports model selection, capacity and cost review without reacting to short noise.

Layer the dashboard from business outcome to component: accepted tasks, errors, latency, provider or model, token usage and cost. A chart that cannot narrow the failing app or model is not actionable during an incident.

Which alerts are actually actionable?

Alert on sustained error-rate increases, p95 latency regression, time-to-first-token regression, abnormal 429 volume, fallback-rate changes, spend anomalies and traffic dropping to zero. Every alert needs a window long enough to avoid paging on one request and short enough to catch user impact.

Attach the application, model, error class and first runbook step to the alert. If the responder cannot inspect a request ID, compare the last deployment and identify the affected tenant, the alert is incomplete.

How do you debug common LLM incidents?

For an error spike, compare status classes and model routes before retrying. For slow responses, separate time to first token from completion time and check streaming, retrieval and tool spans. For a spend spike, compare tokens, retries, fallback and accepted-task count rather than looking only at the invoice.

For quality regressions, correlate prompt or model changes with acceptance results. Keep the prompt version and evaluation dataset separate from raw customer content. The goal is to explain the change and roll it back, not to search logs for a single magical error.

Langfuse, Helicone, Datadog or gateway logs?

Langfuse and Helicone focus on LLM traces, prompts, evaluations and generation-level visibility. Datadog is strongest when LLM telemetry must connect to existing infrastructure and application operations. Portkey combines gateway controls with observability features. Gateway request logs cover the calls the gateway receives and often provide the minimum model, usage, cost and error record.

These roles overlap. Choose by the question you need to answer, the retention and privacy terms you can accept, and how the tool joins existing logs, metrics and incident workflows. A gateway log is not automatically a full evaluation platform, and an evaluation platform may not see provider failures outside the instrumented client.

Where does OpenLux fit in an observability stack?

OpenLux provides console request logs and usage records showing the model, latency, token usage and cost associated with an API call, plus the published error classes documented in the API guide. This makes the gateway a source for request-level usage and failure evidence without requiring a separate vendor integration just to understand spend.

The page does not claim that OpenLux is a complete evaluation or distributed-tracing platform. Teams that need full span capture, custom evaluation datasets, long-term export or arbitrary alert routing should combine the gateway with an observability platform that documents those controls.

What should you never log?

Do not log API keys, authorization headers, unredacted customer records, source code, private documents or full prompts by default. Treat request bodies, response bodies, tool arguments and retrieved content as sensitive until the data owner approves a diagnostic path.

Logging a key label is useful; logging the key value is a credential leak. Logging a document ID can support investigation; logging the full document changes the data-retention obligation. Metadata is not automatically harmless, because timing, tenant and usage patterns can still be sensitive.

A safe request-log schema

This example records operational metadata only. Prompt and response content are intentionally absent.

JSON log record

{
  "timestamp": "2026-11-08T12:00:00Z",
  "request_id": "req_01J8W6G9Z3",
  "application": "support-assistant",
  "environment": "production",
  "key_label": "support-prod",
  "requested_model": "gpt-5.6-sol",
  "returned_model": "gpt-5.6-sol",
  "upstream_provider": "openai",
  "route": "default",
  "retry_count": 0,
  "fallback_used": false,
  "status_code": 200,
  "error_class": null,
  "latency_ms": 1280,
  "time_to_first_token_ms": 410,
  "input_tokens": 1840,
  "output_tokens": 320,
  "cached_tokens": 0,
  "cost_usd": 0.0004,
  "accepted_task": true
}

Key takeaways

  • Start with a safe request record that explains model, latency, error and cost.
  • Do not retain prompts or responses in default logs without an approved data path.
  • Use logs for investigation, metrics for trend detection and traces for multi-step workflows.
  • Alert on user impact and give each alert an owner and first diagnostic step.
  • OpenLux provides gateway request and usage evidence, not a complete evaluation platform.

Frequently asked questions

What is LLM API observability?

It is the ability to explain model-backed requests with logs, metrics and traces covering quality, latency, errors, usage and cost. It should connect an individual request to the behavior of the wider workload.

Should I log prompts and responses?

Not by default. Store operational metadata unless the data owner approves a redacted diagnostic path with limited retention and access control. Prompt payloads often contain customer or source-code data.

Which metrics should I monitor first?

Start with success rate, p95 latency, time to first token, 429 and 5xx rates, retries and cost per accepted task. Segment them by application and model.

What is the difference between logs, metrics and traces?

Logs explain one request, metrics aggregate behavior over time and traces show how one workflow moved across retrieval, tools and model calls.

Do I need a separate LLM observability platform?

It depends on whether gateway logs and existing monitoring answer your evaluation, tracing, export and retention questions. Add a specialist platform when those gaps are measured, not only because the category exists.

Does OpenLux provide observability?

OpenLux provides request-level console logs and usage records with model, latency, token and cost information. It is not positioned as a complete evaluation or distributed-tracing platform.

How long should LLM logs be retained?

Retention depends on data classification, incident needs and contractual obligations. Define a short default, restrict sensitive diagnostic capture and verify that the provider supports your required deletion terms.

Sources and official documentation

Start with one request ID and one owner

Run a representative workload, record safe metadata and verify that logs, usage and cost describe the same request.

Create an API key See pricing

LLM API Observability: Logs, Metrics & Alerts | OpenLux