Core reference
Usage and event streams
Read a leader's usage rows and lifecycle events by cursor, receive the usage push that replaces the usage stream from core v0.4.0, and subscribe to live notifications.
In short
A leader keeps two durable logs, usage rows and lifecycle events, and serves them by cursor. A collector stores the last id it committed and asks for the rows after it, so a restart loses nothing; deduplicate by id. Both need an admin key.
curl -s "http://localhost:8080/admin/v1/events/stream?after=0&limit=100" -H "Authorization: Bearer $ADMIN"From core v0.4.0 the leader keeps no usage rows: it pushes one OTLP log record per request to a receiver you name, and GET /admin/v1/usage/stream is gone. See Usage push. The event stream stays.
A leader keeps two durable logs in its store and serves them by cursor. A collector stores the last id it committed and asks for what comes after it. A replay after a crash re-reads rows the collector already has, so deduplicate by id; no row is lost. Both routes need an admin key.
Usage stream
Replaced in core v0.4.0
This section describes core v0.3.0 and earlier. In core v0.4.0 the usage table and this route leave core, and the feature key usage_stream with them; the leader advertises usage_push instead. A manager that finds usage_stream and not usage_push talks to an older leader and pulls this route as before.
GET /admin/v1/usage/stream?after=ID&limit=N| Parameter | Default | Meaning |
|---|---|---|
after | 0 | Return rows with an id greater than this. |
limit | 500 | Page size, 1 to 1000. |
{
"events": [
{
"id": 1042,
"type": "usage",
"ts": "2026-10-30T10:12:44.123Z",
"data": {
"api_key_id": "k_8sT2…",
"user_id": "alice",
"model": "qwen3-coder-30b",
"protocol": "openai",
"prompt_tokens": 812,
"completion_tokens": 233,
"latency_ms": 4120,
"ttft_ms": 310,
"outcome": "ok",
"cost_usd": 0,
"node_id": "n_abc123"
}
}
],
"next": 1042,
"more": false,
"boot": 1761818000
}| Field | Meaning |
|---|---|
next | The last id in this page. Pass it as after for the next page. |
more | true when more rows wait; ask again at once. |
boot | The leader process's start time (Unix seconds). |
data.api_key_id | The key. Keys from an auth snapshot appear as k_cp_<id>. |
data.protocol | openai, anthropic, vertex, grpc-vertex, … |
data.ttft_ms | Time to the first usable byte of a streamed answer. Absent or 0 on a non-streamed answer. |
data.outcome | ok, error or cancelled. A caller who hangs up mid-stream still leaves a row. |
data.node_id | The worker that served it. Empty = answered locally or never dispatched. A gang request is recorded under shard:<model>:<gang>. |
data.cost_usd | Deprecated and always 0. Opod records tokens, not money. |
The rows are raw facts. Summaries and breakdowns are the consumer's job. A front door's rows reach the leader through POST /admin/v1/usage/push and appear in this stream too.
Cursor ids and restarts
Ids are monotonic within a store and never reused. A managed leader with an in-memory store starts again from 1 after a restart: compare boot with the last value you saw, and when it changed, start from after=0.
Usage push
The usage push is new in core v0.4.0 (feature usage_push). The leader keeps no usage table. Each finished request, its own or one a front door pushed to it, becomes one record in a queue in memory. An exporter sends the oldest records to OPOD_USAGE_OTLP_ENDPOINT as OTLP/HTTP log records and frees them only on a 2xx. Any OTLP/HTTP logs receiver works: an OpenTelemetry Collector, or a control plane.
OPOD_USAGE_OTLP_ENDPOINT=http://otel-collector.example.com:4318/v1/logs \
OPOD_USAGE_OTLP_HEADERS="Authorization=Bearer sk-orc-<printed once>" \
OPOD_USAGE_QUEUE_MB=64 \
opod up| Variable | Default | Meaning |
|---|---|---|
OPOD_USAGE_OTLP_ENDPOINT | empty | The OTLP/HTTP logs URL, a full http:// or https:// URL. Empty = records are held and nothing is sent. |
OPOD_USAGE_OTLP_HEADERS | empty | k=v,k=v, sent on every push. |
OPOD_USAGE_QUEUE_MB | 64 | The queue's size in MiB, about 440,000 records. |
Standalone core needs a receiver to keep usage at all. With no endpoint set, records only wait in the queue, and past the cap the oldest go. Run a collector beside the leader to keep them.
What one push carries
One push is one ExportLogsServiceRequest in protobuf (Content-Type: application/x-protobuf), at most 1 MiB of records. Every record has the event name opod.usage. The names are spelled once in core (pkg/adminapi/usagelog.go).
| Attribute | Where | Meaning |
|---|---|---|
service.name | resource | opod-leader. |
opod.leader.boot | resource | The leader process's start time (Unix seconds). |
opod.usage.seq | record | A sequence that starts at 1 on every boot. |
opod.request.id | record | The X-Opod-Request-Id the caller saw. |
gen_ai.request.model | record | The model. |
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens | record | Prompt and completion tokens. |
opod.api_key.id | record | The key. Keys from an auth snapshot appear as k_cp_<id>. |
user.id | record | The key's user id. |
opod.protocol | record | openai, anthropic, vertex, grpc-vertex, … |
opod.outcome | record | ok, error or cancelled. |
opod.node.id | record | The worker that served it, as data.node_id on the stream. |
opod.latency_ms | record | End-to-end latency. |
opod.ttft_ms | record | Time to the first usable byte of a streamed answer. |
opod.gateway | record | The front door that served it. Absent = the leader. |
gen_ai.usage.cache_read.input_tokens | record | Prompt tokens the engine served from its prefix cache. 0 = none reported. vLLM, SGLang, llama.cpp and TensorRT-LLM report it (read on the design-partner cell, 2026-11-01); Ollama does not. |
opod.request.class | record | The admission class that ranked the request. Absent when the policy has no classes. |
gen_ai.operation.name | record | What the request did: chat, embeddings or rerank. How it was spoken is opod.protocol. |
The record's time is the request's time. A string attribute with an empty value is left off: on the receiver, absent and empty read the same.
Deduplicate on (opod.leader.boot, opod.usage.seq). The leader resends a batch whose answer it did not get, so a receiver that stores each key once takes a resend safely. The record carries no money field.
What the answer does
| Receiver answers | Effect on the leader |
|---|---|
| 2xx | The batch is freed and counted on opod_usage_sent_total. Records a partial success names as rejected are counted on opod_usage_dropped_total{reason="rejected"}. |
400 | The receiver will never take the batch (OTLP): it is freed and counted as rejected. |
| any other status, or a network error | Nothing is freed. The leader backs off from 1 s to 30 s and sends the same records again. Counted on opod_usage_export_errors_total. |
What can be lost
- A full queue. Past
OPOD_USAGE_QUEUE_MBthe oldest record is dropped, counted asreason="full". A record bigger than the whole queue is refused,reason="refused". A receiver sees the loss as a gap in one boot'sopod.usage.seq. - A leader restart. What was queued is lost. The receiver sees a new
opod.leader.boot, not a count.
The queue and its losses are on /metrics; see Metrics.
Event stream
GET /admin/v1/events/stream?after=ID&limit=NSame parameters and paging as the usage stream. The event stream stays in core v0.4.0. Each event:
{ "id": 77, "type": "node.drained", "subject": "n_abc123", "ts": "2026-10-30T10:15:02Z", "data": { "by": "admin" } }subject is the node, model or path the event is about. data is free-form per type. New types are added over time: ignore types you do not know.
| Type | When |
|---|---|
node.registered | A worker registered. |
node.reincarnated | A worker registered with a new boot id under the same node id; the old process's placements and gang rows were dropped. |
node.drained, node.undrained | Drain state changed. |
node.removed | A node was removed by an admin. |
node.forgotten | The leader dropped a node that had been silent too long. |
node.engine_silent, node.engine_reporting | A worker's engine stopped or resumed answering it. |
node.cert-refused | The leader refused a join on its worker certificate. data.reason is revoked (the certificate's serial is on the auth snapshot's revoked list) or id-mismatch (the certificate names another node than the one claimed, in data.claimed); data.serial is the certificate's serial. |
model.added, model.removed | Install or uninstall. |
model.loaded, model.unloaded | Engine memory changed. |
model.move_started, model.move_loaded, model.move_flipped, model.move_drained, model.move_finished, model.move_aborted | Steps of a model move. |
shard.created, shard.removed | A gang formed or was torn down. |
shard.healed, shard.heal_failed | The leader re-formed a gang its plan declares, or failed to; heal_failed carries the gang, the plan revision, error.code and the reason. |
shard.stale | A gang lost a part: its worker restarted (new boot id) or the part's process went down. data.reason says which. |
worker.sleep, worker.resume | Sleep tier changes. |
worker.slow, worker.slow_cleared | Arrives in the core release after v0.4.8. The router started or stopped ranking a worker down for latency (routing.slowFactor). Subject: the node id or the gang key; data: model, factor, metric. Turning the factor off clears every one. |
plan.updated | The plan file changed revision or model. |
auth.updated | A new auth snapshot was applied. |
policy.updated | A new policy snapshot was applied. |
policy.wake_marks | The set of sleepers that must not be resumed in place changed. |
routing.fallback, routing.fallback_failed | The policy's fallback URL answered, or failed. |
admin.call | A state-changing admin call: actor, status and caller address. |
Live notifications (SSE)
GET /admin/v1/eventsServer-sent events for live views. Each event is one line of JSON under a topic:
event: hello
data: {"ok":true}
event: nodes
data: {"topic":"nodes","id":"n_abc123"}Topics: models, nodes, shards, usage, audit. A comment line : keepalive is sent every 25 seconds so proxies keep the connection open. Re-read the related view when an event arrives. The key can be passed as ?key= because a browser EventSource cannot set headers. These notifications are not durable; use the cursor streams for anything you must not miss.
Last updated · Source: content/docs/core-reference/streams.mdx · View as Markdown