
# tdx observability

Read inference traces and calls, the store status and its switch.

Read the gateway's inference observability store: traces (trajectories with their calls and timeline) and individual calls with their attribution. The attribution filters (--key-id, --user-id, --workspace-id, --request-id, and --sessions where offered) apply only with user management on; a gateway without it ignores parameters it does not know, so the reply is then unfiltered by them. status reads the store's state (install-wide status.read); set saves the observability switch for the next restart (install-wide settings.manage).

Every command also takes the [global flags](/cli/reference#global-flags) and reads the [environment variables](/cli/reference#environment-variables) that the command reference lists once.

## Commands

| Command | Description | Type |
|---|---|---|
| [tdx observability traces](/cli/reference/observability#tdx-observability-traces) | Read inference traces. | Group |
| [tdx observability traces list](/cli/reference/observability#tdx-observability-traces-list) | List traces, newest first. | Read |
| [tdx observability traces show](/cli/reference/observability#tdx-observability-traces-show) | Read one trace with its calls and timeline. | Read |
| [tdx observability calls](/cli/reference/observability#tdx-observability-calls) | Read individual gateway calls. | Group |
| [tdx observability calls list](/cli/reference/observability#tdx-observability-calls-list) | List calls, newest first. | Read |
| [tdx observability status](/cli/reference/observability#tdx-observability-status) | Read embedded observability store status. | Read |
| [tdx observability set](/cli/reference/observability#tdx-observability-set) | Save the observability switch for the next restart. | Write |

## tdx observability traces

Read inference traces.

Read inference traces from the gateway's observability store: list a page, or show one trace without its captured text. The attribution filters (--key-id, --user-id, --workspace-id, --request-id, and --sessions where offered) apply only with user management on; a gateway without it ignores parameters it does not know, so the reply is then unfiltered by them.

## tdx observability traces list

List traces, newest first.

**Reads**

Read one gateway page of traces (trajectories) the gateway lets this credential see. No automatic paging: pass nextCursor back with the same filters. The attribution filters (--key-id, --user-id, --workspace-id, --request-id, and --sessions where offered) apply only with user management on; a gateway without it ignores parameters it does not know, so the reply is then unfiltered by them. A --key-id that is not a gateway key id (a ULID) is a secret request parameter: it prints as █, and so does any value that contains it or another &-separated part of the request path, such as model=\<model> after an earlier filter. See [Values too long to print](/cli/reference#values-too-long-to-print). A nextCursor longer than 2048 characters (the gateway puts the last row's id in it) prints as [withheld: too long] while hasMore keeps the gateway's value; --cursor refuses the marker before any request, so page past that row with narrower --since and --until filters. keyHash is withheld; with amounts hidden for this reader costUsd is null. See [Observability filters and output](/cli/reference#observability-filters-and-output).

```bash
# GET /observability/v1/traces
tdx observability traces list [flags]
```

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--since` | datetime |  | Only items starting at or after this instant. |
| `--until` | datetime |  | Only items starting at or before this instant. |
| `--status` | string |  | Status, such as ok or error. |
| `--provider` | string |  | Provider id, passed through as given. |
| `--model` | string |  | Model id, passed through as given. |
| `--agent` | string |  | Agent name. |
| `--project` | string |  | Project id. |
| `--tag` | string |  | Tag. |
| `--search` | string |  | Free-text search the gateway matches. |
| `--key-id` | string |  | Attribution: public API key id. |
| `--user-id` | string |  | Attribution: public user id. |
| `--workspace-id` | string |  | Attribution: public workspace id. |
| `--request-id` | string |  | Request id. |
| `--sessions` | one of `grouped`, `sourced` |  | Grouped or sourced sessions only. |
| `--limit` | integer |  | Page size; the gateway clamps it to 1..200 and defaults to 50. |
| `--cursor` | string |  | Opaque nextCursor from a previous observability traces list page with the same filters; pass it as --cursor=\<nextCursor>. |

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `traces` | public-trace[] | Id, trace id, title, status, agent, project, endpoint, providers, key label, tags, times, counts, session source, client trajectory id, input, output, non-cached input, cached input, cache-creation input, reasoning output and total tokens, costUsd. |
| `summary` | trace-summary | Trajectories, error trajectories, spans, unpriced calls (null when absent), input, output, non-cached input, cached input, cache-creation input, reasoning output and total tokens and costUsd over the whole filtered scope. |
| `money` | 'raw'\|'hidden'\|null | How amounts read for this credential; null when the gateway does not say. |
| `hasMore` | boolean | Whether a further page exists. |
| `nextCursor` | string\|null | Gateway continuation cursor; null on the final page. |

## tdx observability traces show

Read one trace with its calls and timeline.

**Reads**

Read one trace. Trace ids can be client-chosen, so the id is percent-encoded into the path. Captured text (span request and response, error messages and event data) is never printed: textWithheld says whether the reply carried any; it still feeds masking. keyHash is withheld. See [Values too long to print](/cli/reference#values-too-long-to-print) and [Observability filters and output](/cli/reference#observability-filters-and-output).

```bash
# GET /observability/v1/traces/:id
tdx observability traces show --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Trace id as the gateway reported it: 1-512 printable ASCII characters without whitespace; never a credential. |

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `trace` | public-trace-detail | The trace summary fields, captureText, calls (structured fields only) and events (id, request id, time, stage, provider, model). |
| `textWithheld` | boolean | Whether the reply carried captured text the CLI did not print. |

## tdx observability calls

Read individual gateway calls.

Read individual calls (provider calls and gateway request outcomes) with attribution. Requires a gateway with user management on.

## tdx observability calls list

List calls, newest first.

**Reads**

Read one gateway page of calls with their attribution and usage. The route exists only with user management on; without it the gateway answers 404 and this exits 5 NOT_FOUND. JSON only: the gateway's CSV export (format=csv) is not offered. The attribution filters (--key-id, --user-id, --workspace-id, --request-id, and --sessions where offered) apply only with user management on; a gateway without it ignores parameters it does not know, so the reply is then unfiltered by them. A --key-id that is not a gateway key id (a ULID) is a secret request parameter: it prints as █, and so does any value that contains it or another &-separated part of the request path, such as model=\<model> after an earlier filter. See [Values too long to print](/cli/reference#values-too-long-to-print). A nextCursor longer than 2048 characters (the gateway puts the last row's id in it) prints as [withheld: too long] while hasMore keeps the gateway's value; --cursor refuses the marker before any request, so page past that row with narrower --since and --until filters. Directory entries name the keys, people and workspaces the page refers to, as arrays of id, name and state. Gateway key ids (ULIDs) print in clear, in calls and in the directory, as do the directory's key names and states. If any directory key id is not a ULID, every key name and state there of 8 or more characters prints as █ wherever it appears; under an id that contains a secret-like word such as KEY, that entry's name and state of 8 or more characters print as █ wherever they appear. See [Observability filters and output](/cli/reference#observability-filters-and-output).

```bash
# GET /observability/v1/calls
tdx observability calls list [flags]
```

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--kind` | one of `provider_call`, `gateway_request_outcome`, `all` |  | Provider_call, gateway_request_outcome or all; omitted uses the gateway default (all). |
| `--since` | datetime |  | Only items starting at or after this instant. |
| `--until` | datetime |  | Only items starting at or before this instant. |
| `--status` | string |  | Status, such as ok or error. |
| `--provider` | string |  | Provider id, passed through as given. |
| `--model` | string |  | Model id, passed through as given. |
| `--agent` | string |  | Agent name. |
| `--project` | string |  | Project id. |
| `--tag` | string |  | Tag. |
| `--search` | string |  | Free-text search the gateway matches. |
| `--key-id` | string |  | Attribution: public API key id. |
| `--user-id` | string |  | Attribution: public user id. |
| `--workspace-id` | string |  | Attribution: public workspace id. |
| `--request-id` | string |  | Request id. |
| `--limit` | integer |  | Page size; the gateway clamps it to 1..200 and defaults to 50. |
| `--cursor` | string |  | Opaque nextCursor from a previous observability calls list page with the same filters; pass it as --cursor=\<nextCursor>. |

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `calls` | public-call[] | Id, kind, status, structured error, trajectory id, times, endpoint, provider, model, finish reason, tags, key/user/workspace ids, principal kind, input, output, non-cached input, cached input, cache-creation input, reasoning output and total tokens, costUsd, usageReported, costReported. |
| `summary` | call-summary | Calls, coverage, input, output, non-cached input, cached input, cache-creation input, reasoning output and total tokens, costUsd and refused (null when absent) over the whole filtered scope. |
| `money` | 'raw'\|'hidden'\|null | How amounts read for this credential. |
| `directory` | public-directory | Keys, users and workspaces: arrays of id, name and state. |
| `hasMore` | boolean | Whether a further page exists. |
| `nextCursor` | string\|null | Gateway continuation cursor; null on the final page. |

## tdx observability status

Read embedded observability store status.

**Reads**

Requires install-wide status.read. Reads GET /observability/v1/status: the store state, whether the embedded store is live in this process (enabled), the resolved switch it will use at the next start (configEnabled; null when the gateway omits it for a live store), text capture, trace and span counts, retention and ingest health. Every printed value comes from one fail-closed masking pass over the request, the whole gateway reply (including fields the CLI drops) and the CLI's projection, before selection/jq; █ marks masked values. state is printed as the CLI's own validated literal. A reply that cannot be masked within the fixed limits fails with OUTPUT_MASK_LIMIT (exit 7) and no values; a malformed reply fails with INVALID_RESPONSE (exit 7). --dry-run still performs this read.

```bash
# GET /observability/v1/status
tdx observability status [flags]
```

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `state` | string | Store state: ok, degraded or disabled. |
| `enabled` | boolean | Whether the embedded store is live in this gateway process. |
| `configEnabled` | boolean\|null | While disabled: the resolved switch for the next start; null when a running store omits it. |
| `captureText` | boolean | Whether raw text capture is on. |
| `traces` | integer | Stored traces. |
| `spans` | integer | Stored spans. |
| `oldestStartedAt` | string\|null | Oldest stored trace start. |
| `newestStartedAt` | string\|null | Newest stored trace start. |
| `storageBytes` | integer\|null | Store size in bytes, when known. |
| `retention` | store-retention | Maximum age, bytes and traces, and last prune time. |
| `ingest` | store-ingest | Queue depth and capacity, dropped events, degraded flag and last error time. |

**Examples**

Read the masked public projection as versioned JSON:

```bash
tdx observability status --json
```

Select declared output fields:

```bash
tdx observability status --json=state,enabled,configEnabled
```

**See also:** [tdx observability set](/cli/reference/observability#tdx-observability-set), [tdx audit status](/cli/reference/audit#tdx-audit-status)

## tdx observability set

Save the observability switch for the next restart.

**Writes**

Requires install-wide settings.manage. Sends PUT /control/observability with body exactly `{"enabled": <boolean>}`. The gateway persists the saved switch and returns it. It applies at the gateway's next restart unless TOKEDEX_OBSERVABILITY (or its alias TOKEDEX_OBSERVABILITY_STORE) is set there, which overrides it. While the store is disabled, observability status shows the resolved next-start value as configEnabled; a running store does not report it. Dry-run reads no saved profile, sends no request and creates nothing; it requires no credential source, and TOKEDEX_TOKEN, when set, is used only to mask the preview. The gateway has not checked its preview. Before sending, the request is masked alone; if that hits the fixed limits the command fails with OUTPUT_MASK_LIMIT (exit 7) and nothing is sent. The printed value comes from one fail-closed masking pass over the request, the whole gateway reply and the projection; an accepted write whose reply is invalid or cannot be masked fails with CHANGE_APPLIED_RESPONSE_INVALID (exit 1) and no values.

```bash
# PUT /control/observability
tdx observability set --enabled <true|false> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--enabled` | one of `true`, `false` |  | Save observability on (true) or off (false). |

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `enabled` | boolean | The switch the gateway persisted. |
| `preview` | write-preview\|null | Requested change, unchecked by the gateway; null after execution. |

**Examples**

Save observability on for the next restart:

```bash
tdx observability set --enabled true --json
```

Preview turning it off without any read or request:

```bash
tdx observability set --enabled false --dry-run --json
```

**See also:** [tdx observability status](/cli/reference/observability#tdx-observability-status)
