Skip to main content
Version: Latest (main)

API and Observability

Overview​

This page covers the shared runtime blocks that expose interfaces and telemetry.

These settings are router-wide and belong in global:, not in route-local plugin fragments.

Key Advantages​

  • Keeps observability and interface controls consistent across routes.
  • Avoids duplicating metrics or API settings inside route-local config.
  • Makes replay and response APIs explicit shared services.
  • Keeps operational controls in one router-wide layer.

What Problem Does It Solve?​

If API and telemetry behavior is configured per route, the operational surface becomes fragmented and hard to reason about.

This part of global: solves that by collecting shared interfaces and monitoring settings in one place.

When to Use​

Use these blocks when:

  • the router should expose shared APIs
  • the response API should be enabled for the whole router
  • metrics and tracing should be configured once
  • replay capture should be retained as a shared operational service

Configuration​

Router config validation​

The management API validates and normalizes a candidate config without writing it:

POST /api/v1/config/validate
Content-Type: application/json

{"yaml":"version: v0.5\n..."}

Successful responses include valid: true and the normalized canonical YAML. Validation uses the same parser and semantic checks as PATCH /api/v1/config and PUT /api/v1/config, but preserves ${ENV_VAR} references verbatim rather than reading process secrets. The endpoint requires config.read; plaintext secret viewing is not implied.

API​

global:
services:
api:
routing_preview:
request_timeout_seconds: 120
max_concurrency: 16
batch_classification:
max_batch_size: 100

max_batch_size bounds texts per /api/v1/diagnostics/classify/batch request. Larger batches return 400 INVALID_INPUT.

routing_preview applies to POST /api/v1/routing/preview:

SettingMeaningDefaultChange
request_timeout_secondsThe inference deadline, from when the request body is decoded; 1 to 3600. Set it from measured inference times for your input lengths and hardware.120Hot reload
max_concurrencyA positive worker limit with no wait queue: when every slot is busy, new previews return 429 OVERLOADED.16Restart; hot reload rejects it

A deadline returns 504 REQUEST_TIMEOUT and cancels the preview's model calls: the model runtime skips work it has not started and finishes a pass already running. The admission slot frees once those calls return. Other HTTP routes keep their own timeouts.

The response writer has five additional seconds to send the result or timeout response. Dashboard Topology uses the configured Preview budget plus this allowance and propagates client cancellation. Recipe probes retain their own evaluation.request_timeout_seconds caller budget in probes.yaml; configure it for the intended run, and allow at least five extra seconds in external HTTP clients or proxies when they need to receive the Router's timeout response.

Authz​

global:
services:
authz:
fail_open: false
identity:
user_id_header: x-authz-user-id
user_groups_header: x-authz-user-groups
providers:
- type: header-injection
- type: static-config
delegated_credential:
enabled: false
header: x-vsr-delegated-credential

identity names the headers an authenticating gateway sets for the user and their groups. providers is the credential chain for upstream provider keys, and the first match wins:

  • header-injection reads the per-user keys an ext_authz service injected.
  • static-config falls back to the api_key of the selected backend.

fail_open: true lets a request through with no key at all.

delegated_credential names the header in which a deployment authenticator attaches the credential it issued the requesting user:

  • Only delegated upstreams receive it. An upstream whose auth is credential: delegated (a backend_refs entry or a deployment) gets it under its own auth header, and only on a call made for that request.
  • A request without it is answered 401 before the call.

See Security Hardening.

Response API​

global:
services:
response_api:
enabled: true
store_backend: redis # default; use "memory" only for local development
redis:
address: "redis:6379"

The store_backend field controls where response and conversation history is persisted. Available backends:

BackendDurabilityUse case
redisSurvives router restart, shared across replicasProduction (default)
memoryLost on router restartLocal development only

The redis store needs redis.address (or cluster_addresses in cluster mode). When the store cannot start, the router still starts, logs response_api_store_init_failed, and answers every /v1/responses request with 503 and code response_store_unavailable. Set enabled: false to serve no Responses API at all, which answers 404.

Observability​

global:
services:
observability:
metrics:
enabled: true
tracing:
enabled: true
provider: opentelemetry
exporter:
type: otlp
endpoint: jaeger:4317
insecure: true
sampling:
type: probabilistic
rate: 0.1

probabilistic is the recommended tracing sampling type. Existing configurations that use traceidratio or trace_id_ratio continue to work as compatibility aliases.

Common Prometheus metric families:

FamilyExample metrics
Terminal requestsllm_request_outcomes_total, llm_request_duration_seconds (by bounded traffic_kind and outcome)
Backend dispatch and error eventsllm_model_requests_total, llm_request_errors_total (not a completed-client-request denominator)
Latencyllm_model_completion_latency_seconds, llm_model_first_response_observation_seconds, llm_model_response_duration_per_output_token_seconds, llm_model_routing_latency_seconds
Tokens and costllm_model_tokens_total, llm_model_prompt_tokens_total, llm_model_completion_tokens_total, llm_model_cost_total
Routingllm_model_routing_modifications_total, llm_routing_reason_codes_total
Selectionllm_model_selection_total, llm_model_selection_duration_seconds, llm_model_inflight_requests
Looperllm_looper_attempts_total, llm_looper_attempt_duration_seconds, llm_looper_attempt_first_byte_seconds, llm_looper_attempt_tokens_total, llm_looper_attempt_cost_total, llm_looper_execution_duration_seconds
Request graphsllm_request_graph_node_duration_seconds (by node_type and template)
Cachellm_cache_plugin_hits_total, llm_cache_plugin_misses_total, llm_cache_warmth_estimate
RAGrag_retrieval_attempts_total, rag_retrieval_latency_seconds, rag_cache_hits_total, rag_cache_misses_total
Router Memoryllm_memory_retrieval_total (backend, status), llm_memory_retrieval_latency_seconds, llm_memory_retrieval_results, llm_memory_store_operations_total, llm_memory_cache_hits_total, llm_memory_cache_misses_total, llm_memory_extraction_total
Sessionllm_session_model_transitions_total, llm_session_turn_prompt_tokens, llm_session_turn_completion_tokens, llm_session_turn_cost
Translation and request-parameter policyllm_translation_lossy_total (by reason, with any count in it written as N), sr_request_params_blocked_total
Signalsllm_signal_extraction_total, llm_signal_match_total, llm_signal_extraction_latency_seconds
Configuration lifecyclellm_config_updates_total (source, result, stage), llm_config_update_duration_seconds, llm_config_active_version, llm_config_active_info (version, hash), llm_config_last_rejection_timestamp_seconds
Remote model callsllm_remote_connector_requests_total (by operation, outcome), llm_remote_connector_request_duration_seconds, llm_remote_connector_retries_total
Recipe routingllm_entrypoint_requests_total, llm_recipe_selections_total, llm_routing_stage_duration_seconds (stages signals, decision, algorithm, prompt_compression), llm_prompt_compression_total (by recipe and outcome: compressed, skipped_disabled, skipped_min_length, skipped_max_tokens)
Context windowllm_context_window_checks_total (by count: exact or proxy, and verdict: fits, in_band or exceeds), llm_context_window_refusals_total (by count), llm_context_window_margin (by count), llm_context_window_wait_seconds, llm_context_window_tokenizer_loaded (by tokenizer), from the context window check
Routing inputllm_routing_input_removed_total (by kind: skipped_message, stripped_block), from global.router.routing_input
Streamed request bodyllm_streamed_body_arrival_seconds, llm_streamed_body_bytes, llm_streamed_body_chunks (by recipe; STREAMED and FULL_DUPLEX_STREAMED modes only)
Projectionsllm_projection_score (by configured recipe and projection name)
Trace exportllm_trace_export_spans_total (by exporter batch result)

Router Memory counters use bounded labels only. See the Router Memory Prometheus label release note.

A request that names a model the configuration does not serve counts in llm_request_errors_total as model="unknown", reason="model_not_found"; the specified_model_not_found log event keeps the name it sent.

llm_request_graph_node_duration_seconds times each step of a request graph, such as a Looper template's algorithm and respond steps; a step that holds others counts their time too. template names the graph (looper.fusion, for example) and node_type the step's registered type.

llm_request_outcomes_total{traffic_kind="inference"} counts each public inference request once, at its terminal boundary:

  • Traffic kinds. Authenticated internal looper requests use inference_internal; catalog, response-object and health operations have their own kinds.
  • Outcomes distinguish success, client and server errors, cancellation, timeout, incomplete responses and other failures.
  • One request, one count. A backend selection or an error event is not another completed public request.

The model latency names describe what they observe:

MetricMeasures
llm_model_first_response_observation_secondsThe first stream chunk, or a non-streaming response's headers, of successful responses only
llm_model_response_duration_per_output_token_secondsComplete response time divided by reported output tokens

Neither is first-token latency or decode-only inter-token latency. The optional windowed metrics summarize at most 10,000 completed responses per model; they don't estimate utilization, queue depth or provider error rates.

The semantic_router.request span covers the complete ExtProc request, streamed responses and cancellation included:

  • Bounded labels. Its traffic.kind and route separate inference from catalog or health polling, without storing URL queries or resource IDs.
  • Child stages: signal evaluation, decision evaluation, algorithm selection, plugins, and the actual upstream request.
  • Routing attributes. routing.entrypoint, routing.recipe, decision.name and routing.algorithm identify the routing boundary where available.
  • Selection and duration. A routing.backend.resolved event records selection evidence; the upstream span measures provider duration.
  • Status. If a local response guard blocks an upstream HTTP 200, the upstream span keeps 200 while the root records the final client status.

The upstream span also carries OpenTelemetry GenAI attributes, so GenAI-aware trace backends can show each provider call:

AttributeValue
gen_ai.operation.namechat
gen_ai.provider.nameThe provider
gen_ai.request.modelThe provider model ID sent upstream
gen_ai.usage.input_tokens, gen_ai.usage.output_tokensAs the provider reports them; unset, never estimated, when it doesn't
gen_ai.response.modelBuffered responses only

model.name keeps the Router's logical model name. The GenAI conventions are still in Development status upstream, so their attribute names can change.

  • Signal evidence events carry finite reported values and confidence separately, real zeros included; missing evidence stays absent, and aggregate signal evaluation never invents a confidence score.
  • Projection events carry evaluated scores and configured names.
  • Never in traces: raw prompts, signal errors and retrieval exception text. Earlier traces cannot be enriched after the fact.

The local vllm-sr serve stack provisions the vLLM Semantic Router dashboard in Grafana:

  • Main groups: public inference outcomes, recipe workflow, backend usage, plugins and response cache, and telemetry health.
  • Accounting and MoM panels separate reported model usage from supported looper attempt evidence.
  • Means, not quantiles. Recipe stage duration and the model timing panels are observed means; projection counts show evaluations, with individual scores in Insights.
  • Sources. Prometheus scrapes both the Router and Jaeger's internal admin metrics.
note

An absent series means no measurement, not zero traffic or a healthy collector. Export success counts completed SDK exporter batches; it does not prove that every request was sampled or retained.

Local telemetry storage:

StoreWhereRetention
JaegerThe pinned all-in-one image, non-root Badger storage in the <jaeger-container-name>-data volume at /tmp7 days
GrafanaDatabase and preferences in <grafana-container-name>-data at /var/lib/grafana, as the image's non-root user—
PrometheusIts local TSDB15 days
  • Replacing a container keeps these stores; deleting one starts a new history. Keep telemetry resets separate from benchmark, authentication, learning and configuration stores.
  • Moving an older in-memory Jaeger to Badger doesn't migrate its memory.
  • Sampling stays controlled by the Router configuration, and a search limit is not a count of all retained traces.
  • For multi-node trace storage, configure an external collector and storage instead of sharing this single-node Badger volume; see the Jaeger 1.76 storage documentation.

Looper metric labels are restricted to bounded algorithm, stage, status, reason, token-type, and currency values. Request IDs, trace IDs, ordinals, decision names, model names, scores, and thresholds are available through traces or detailed Router Replay rather than Prometheus labels. Detailed attempt metrics currently cover the Confidence algorithm; absent attempt evidence must not be interpreted as zero calls or complete cost accounting.

Profiling​

The Router can expose Go pprof endpoints on a dedicated listener for CPU, heap, goroutine, and execution-trace investigations.

global:
services:
observability:
profiling:
enabled: false # default; opt in only while investigating
port: 6060 # default
bind: 127.0.0.1 # default; loopback only

Profiling is disabled by default. When enabled it binds 127.0.0.1:6060, so profiles stay reachable from the Router container or host and are never published on a routable interface without an explicit bind change.

go tool pprof http://127.0.0.1:6060/debug/pprof/heap

Notes:

  • bind must be an IP address or localhost. An empty or hostname value is rejected and the profiling listener is skipped.
  • An explicit port: 0 requests an ephemeral port; the effective address is reported in the profiling_server_starting startup log line.
  • The port must not collide with the ExtProc, metrics, or management API port. A conflicting or unbindable listener is logged and skipped; it does not abort Router startup.
  • This switch is read once at startup. Changing it requires a Router restart; config hot reload does not take over the profiling listener.

Skip Processing Header​

global.router.skip_processing.enabled is the deployment-level gate that opts the router into honoring the x-vsr-skip-processing request header. When the gate is on and an upstream filter sets that header to true, the router becomes a no-op for that single request — every Envoy ext_proc callback returns CONTINUE without classifying, routing, mutating, caching, or inspecting the request or upstream response. When the gate is off (the default) the header is ignored entirely.

global:
router:
skip_processing:
enabled: false # default; flip to true to honor the header

The Helm chart exposes the same gate as a top-level value (router.skipProcessing.enabled) so it can be enabled at install time without editing the embedded canonical config:

helm install vsr oci://ghcr.io/vllm-project/charts/semantic-router \
--version 0.0.0-latest \
--set router.skipProcessing.enabled=true

Enable this gate only when an authenticated upstream filter (Envoy AI Gateway, ext_authz, route-level filters, etc.) is responsible for setting or stripping the header on trust grounds. Background on the AI Gateway interop pattern that motivates this gate lives in issue #1808.

Debug Headers​

global.router.headers.debug decides who may turn on the debug response header, x-vsr-trace, with x-vsr-debug: true. The trace names the signal and guard rules a request matched, so access is off by default:

ValueHonors x-vsr-debug from
none (default)No client
anyEvery client; for development and tests
authenticatedOnly the users and groups in debug_principals, as the identity headers your authenticator sets assert them
global:
router:
headers:
debug: authenticated
debug_principals:
groups: [platform-sre]

See VSR routing headers for what the trace carries.

Router Replay​

global:
services:
router_replay:
store_backend: postgres # explicit durable, SQL-queryable audit storage
async_writes: true
postgres:
host: postgres
port: 5432
database: vsr
user: router
password: ${ROUTER_REPLAY_POSTGRES_PASSWORD}
plugins:
- type: router_replay
configuration:
enabled: true

Router replay is disabled by default:

  • Router-wide. A router_replay plugin in global.plugins turns it on.
  • Per recipe or decision. A recipe's or decision's router_replay plugin overrides it: enabled: false turns capture off there, and enabled: true opts in when the default is off.
  • Storage. Without a durable backend, the default in-memory store is process-local and lost on restart.

The store_backend field controls where routing-decision replay records are persisted. Available backends:

BackendDurabilityUse case
postgresFull SQL queryability, long-term audit retentionProduction audit storage
redisSurvives router restart, shared across replicasLightweight deployments already running Redis
milvusVector-searchable replay recordsSemantic replay search
qdrantVector-searchable replay recordsSemantic replay search in a Qdrant deployment
memoryLost on router restartLocal development only

Data and Security​

  • Response API and Router Replay may persist prompts, responses, routing outcomes, and tool traces. Set TTLs, capture limits, tenant/user scope, and read permissions before enabling them.
  • Bind the management API to a private interface or enable its role-based token authentication before remote exposure.
  • Traces and metric labels should carry bounded identifiers, not raw request content or secrets.
  • pprof endpoints expose command-line arguments, goroutine stacks, and heap contents. Keep profiling disabled outside an investigation, and keep its bind on loopback unless a reachable listener is deliberately fronted by authenticated access controls.
  • See the complete service configuration in config/config.yaml.