# Topics

**Last updated:** 2026-11-25T12:24:54-03:00 (UTC-3)

[Evaluations](/docs/features/evals/) · [Trace explorer](/docs/features/trace-explorer/) · [Query language](/docs/features/query-language/) · [Content capture](/docs/features/content-capture/) · [Alert rules](/docs/features/alert-rules/) · [Access control](/docs/features/access-control/)

Topics answers the question a request log cannot: **what is all this traffic about?** The gateway reads finished traces (or sessions, or coding-agent runs), has one of your own models describe each from several angles, groups the descriptions and names the groups. You get a map of your traffic: what people ask for, how they feel, how runs end and what goes wrong, each topic with its spend, latency, error rate and evaluation pass rate, and a filter that takes you from a topic to its traces.

Nothing leaves your deployment: the summary, embedding and naming calls go through this gateway to the model aliases you choose, with your own provider keys, as ordinary requests of the owning team. They are billed to that team, bounded by a daily budget and shown as their own line in usage.

The feature is off by default. It has three flags:

| Flag | What it turns on | Needs |
| --- | --- | --- |
| `topics` | Maps, facets, the Topics screen, the API, the MCP server, the `gateway topics` commands and the `topic.` term of the query language | `evals`, `span_store` |
| `topics_findings` | Findings raised as [alerts](#findings): topic changes, and cost and reliability detectors that need no map | `alert_rules`, `span_store` |
| `topics_custom_facets` | Teams write their own facets | `topics` |

## Start here

1. **Turn on what Topics reads.** Topics groups stored traces, so the span store must be on (`span_store`), and a model may only read content your capture policy keeps for evaluation: turn on `content_capture` and `content_capture_evaluation` and give the team a [capture policy](/docs/features/content-capture/) whose `purposes` include `evaluation`. Turn on `usage_valuation` and price the models you will name below: helper spend that cannot be valued cannot be bounded, and a map pauses when it meets a call with no known cost.
2. **Name two models** in the `topics` block (or in **Evals → Topics → Settings**):

   ```yaml
   features:
     topics: true
   topics:
     summary_model: summaries      # a chat alias; a small, cheap model is the right choice
     embedding_model: embeddings   # an embeddings alias
   ```

   `naming_model` defaults to `summary_model`, so two aliases are enough. The summary model must return JSON for a JSON schema (structured output).
3. **Create a live map** in **Evals → Topics → New live map**: choose the team, leave the unit at *trace*, keep the four model facets and Signals, and press **Estimate** to see how many units match and what a unit costs before you create it.
4. **Wait for the first fit.** The map summarises its newest 500 units at once and is fitted when nine in ten of them are done. With 100 summaries or more a facet is fitted in standard mode; with fewer it is fitted in small-sample mode (from 10), or you can ask for small-sample mode when you create the map.
5. **Read the map**: pick a facet, look at the table, the treemap or the scatter, open a topic, and press **Open in Traces**.

A map that only uses the **Signals** facet needs no model, no content capture and no budget: it is a good first map on a deployment that captures no content.

## How it works

```mermaid
flowchart LR
  A[Finished unit<br/>trace, session or run] --> B{Content kept<br/>for evaluation?}
  B -- no --> S[Signals only<br/>from span fields]
  B -- yes --> C[One summary call<br/>all facets at once]
  C --> D[One embedding call]
  D --> E[(Summaries<br/>sealed text + vectors)]
  S --> E
  E --> F[Fit: cluster in the gateway,<br/>name from summaries]
  F --> G[(Topics + assignments)]
  E -- later units --> H[Serving rule:<br/>nearest topic within its radius]
  H --> G
  G --> I[Screen, API, MCP,<br/>explorer filter, rules, findings]
```

- **Unit.** What is described and grouped: a **trace** (the default), a **session** (with `session_tracking`) or a recognized coding-agent **run** (with [`agent_recognition`](/docs/features/agent-recognition/)). A map of runs with the Intent facet is the task profile of your coding agents: what they are used for, with requests, cost and p95 per model deployment inside each task.
- **Ready.** A unit is read once it has been idle for `readiness_idle` (5 minutes by default). A unit still receiving spans after an hour is read as it is.
- **Selection.** A map has a filter (a [query](/docs/features/query-language/) over the fields of a trace) and a sample rate. Sampling is deterministic on the unit's ID, so replicas agree and a refit sees the same units. The gateway's own helper and judge calls are never selected, so Topics never summarises itself.
- **Summary.** One model call per unit covers every facet that has no stored summary yet. The model reads the **sent view** of the unit's captured requests (the request after the input guardrails masked it) and the answers: roles and text, tool calls by name with bounded arguments, tool results bounded. Reasoning, tool definitions and inline media are never sent. A transcript longer than `max_input_chars` is recorded as `input_too_large` and never truncated.
- **Embedding.** The applicable summaries of a unit are embedded in one call. The embedding model and its size are locked once summaries exist; see [changing the embedding model](#changing-the-embedding-model).
- **Fit.** Clustering runs inside the gateway, in pure Go, seeded: the same summaries give the same topics on every replica. Topics smaller than `min_topic_members` are not published; their units are outliers. Each topic gets a centroid and a radius.
- **Name.** One call per new or changed topic gives a name of two to seven words and a one-sentence description, written **only from summaries** (text the summary model already wrote from the masked view), never from a transcript. Names are unique within a facet. A name you give is pinned and no refit rewrites it.
- **Live assignment.** A unit that arrives after the fit is summarised and placed at once: the nearest topic when the unit is within that topic's radius, otherwise an outlier (there is no fallback to a farther topic). It is counted, listed and filterable immediately; it gets a point on the scatter at the next fit.
- **Refit.** A live map is fitted again on `refit.schedule` (04:00 UTC daily by default) when new summaries arrived, over the last `refit.window_days`. A topic whose members are mostly the same keeps its ID and its name; after a split the larger part keeps the identity; a topic with no successor is retired, never deleted, so a saved query that names it still parses.
- **Snapshot.** A one-off fit over a window you choose (at most 30 days). It reuses stored summaries for free, may summarise up to `snapshot_max_new_summaries` more, and is frozen afterwards.

### Facets

A facet is one way of describing a unit. Five are built in:

| Facet | What the summary says | Grouping |
| --- | --- | --- |
| **Intent** | What the requester wanted, as one imperative phrase | Clustered |
| **Sentiment** | How the end user felt, from the end user's own text; not applicable to automated runs | By label first: Negative, Mixed, Neutral, Positive |
| **Outcome** | How the run ended, judged from results and not from what the assistant claimed | By label first: Completed, Partial, Not completed, Needs input, Unconfirmed, Not supported |
| **Issues** | What went wrong, in generic words; not applicable when nothing did | Clustered |
| **Signals** | The most severe thing the gateway itself saw: Guardrail block, Answer cut, Timeout, Provider error, Tool error, Content filter, Fallback, or Clean | By label; **no model, no content** |

Sentiment and Outcome are grouped by their label first, one topic per label, so four sentiments are never split into nine near-synonyms. A label is clustered inside only when it holds `label_split_min` units or more (200 by default); its clusters are children of the label's topic.

With `topics_custom_facets`, a team writes its own facet in **Evals → Topics → Facets**: a key, a name, a prompt that says what to describe and in what form, and optionally a closed list of labels (which makes it label-first). A change of the prompt or the labels makes a new version; the new version summarises new traffic only, and a fit never mixes versions. At most 20 facets per team.

When a facet has more than 12 topics, one more call proposes two to eight parents; the table shows the hierarchy.

## What you see

- **Table.** One row per topic: units and share, spend, average cost, p50 and p95 duration, error rate, evaluation pass rate, tokens, and the change against the previous window of the same length; a NEW badge on a topic first seen inside the window. Sort by any column.
- **Treemap.** Topics sized by units or by spend.
- **Scatter.** The units the last fit placed, on the first two principal components of the cohort, coloured by topic.
- **Topic detail.** Description, parent and children, units per day, representative summaries, the member list, and a table of **model deployments**: requests, average cost, p95 and errors per model alias and provider inside the topic.
- **Actions on a topic.** *Open in Traces* (the explorer filtered by the topic), *Add to dataset*, *Create evaluator*, *Rename or pin*, *Merge into*, *Mute findings*.
- **On a trace.** One chip per facet with the trace's topic.

Per-topic spend is the sum of the valued cost of the topic's units, and its p95 is the trace explorer's p95 for the same filter. Spend is shown to readers who see cost in the request log (`usage_valuation` and `analytics:read`).

### The topic term of the query language

With `topics` on, the [trace explorer](/docs/features/trace-explorer/) and evaluator rule filters take a topic term:

| Term | Keeps |
| --- | --- |
| `topic.intent:"Export Data"` | Units of the topic with that name, in the live maps you see (a name is always quoted; add `*` after the quotes for a prefix) |
| `topic.issues:outlier` | Units that were assigned to no topic of the facet |
| `topic.sentiment:none` | Units with no assignment in the facet at all (not yet read, or the facet did not apply) |
| `topic.intent:*` | Units assigned to some topic of the facet |
| `topic.id:tp_0123456789abcdef` | Units of one topic by its ID, of a live map or a snapshot |

It combines with every other term: `topic.intent:"Export Data" status:error -cache:hit`. The filter is exact for a topic of any size: each engine reads it as a join on the assignments, not as a list of trace IDs. The request log (`q` on Logs) and alert rules do not take topic terms.

### Evaluators targeted at a topic

Put a topic term in an [evaluator rule's](/docs/features/evals/) filter:

```json
{"team_id": "team_support", "name": "refund quality", "evaluator_id": "ev_…", "sample_rate": 1,
 "filter": {"query": "topic.intent:\"Request a Refund\""}}
```

With [evaluators](/docs/features/evaluators/#evaluators-targeted-at-a-topic) on, the rule becomes the evaluator's own filter, and an evaluator of a span, a trace or a session takes the term the same way. Such a rule judges nothing when a request is captured, because its topic is not known yet. It runs when the request's unit is assigned to the topic, minutes later. **Create evaluator** on a topic writes a draft judge prompt from the topic's description and representative summaries, with this filter; you review and save it in the evaluator form.

**Add to dataset** copies the captured requests of a topic's newest units (up to 100) into a dataset through the dataset's own import: you need `evals:manage`, write access to the dataset and `content_sent:read` of the team, and the read is audited. Units with nothing you can import are left out and counted.

## Findings

With `topics_findings` (and `alert_rules`), the gateway raises findings as alerts: one alert per root cause, reopened when it returns, resolved by the gateway when a later pass no longer finds it, delivered to the channels in `topics.findings.channels`. Each carries its impact and up to five evidence traces. No finding calls a model or reads content. Read them on the **Alerts** screen or with `GET /api/v1/admin/alerts?source=topics` (or `source=insights`).

| Finding | Source | Fires when | Impact shown |
| --- | --- | --- | --- |
| `new_topic` | topics | A topic first seen in the window holds `min_units` or more | Units |
| `share_spike` | topics | A topic's share of its facet is `spike_ratio` times the previous window's | Units, spend |
| `spend_spike`, `latency_spike`, `error_spike` | topics | The topic's spend, p95 or error rate is `spike_ratio` times the previous window's | Spend, units |
| `issue_growing` | topics | A topic of the Issues facet holds `spike_ratio` times the units it held | Units |
| `negative_sentiment` | topics | The share of Negative units of a map is `negative_share` or more | Units |
| `pass_rate_drop` | topics | A topic's evaluation pass rate fell by `pass_rate_drop` or more | Units |
| `uncached_prompts` | insights | A model received `min_units` prompts of `cache_prefix_tokens` or more and none read the provider's prompt cache | Spend of those calls (the input share is recoverable at most) |
| `large_tool_results` | insights | A tool's results add `large_tool_result_tokens` or more to the next call's input | Added input tokens |
| `verbose_output` | insights | Answers of a model are `verbose_ratio` times its median length | Excess output tokens |
| `tool_errors` | insights | One tool failed `tool_error_min` times | Calls |
| `retry_loop` | insights | A trace calls one tool `retry_loop_min` times in a row | Traces |
| `wasted_spend` | insights | Traces that ended in error cost `min_impact_usd` or more | The exact valued cost, each call once; a lower bound when spans are sampled |

The `insights` findings read stored request and tool spans per team and need no map. *Mute findings* on a topic silences the topic findings about it.

## Cost controls

- **Daily budget.** `budget_usd_per_day` (1 US dollar by default) bounds the helper spend of one organization per UTC day (of one team, on a gateway without organizations). The spend is read from the ledger before every batch, before every facet a fit names and every 10 naming calls within it, so what is in flight when the budget is reached still finishes: at most one batch per working map on each replica (`worker.batch_size` units, each one summary and one embedding call per facet), and 10 naming calls. Set the budget with that margin in mind. When the budget is reached every active map of the organization goes to `paused_budget`, one alert is raised, and reads keep working. **Resuming is explicit**: press Resume, or `PATCH` the map with `{"status":"active"}`. A map may also have its own lower daily cap. `0` stops every model call.
- **Provider refusals.** A credential, a missing model or an exhausted quota pauses the map (`paused_provider`) with the reason; nothing retries a refusal in a loop.
- **Estimate first.** `POST /api/v1/admin/topics/maps/estimate` reads the gateway's own token counts of 50 matching traces, calls no model and reads no content.
- **Summaries are reused.** A second map of the same team, a snapshot and a refit pay nothing for units that already have a summary of the facet at its current version.
- **Sampling.** `sample_rate` on a map.
- **Its own line in usage.** Helper calls carry the helper kinds `topic_summary`, `topic_embedding` and `topic_naming` (with `evaluation_tracing`, filter the request log by origin *helper*), the principal `topics:<map id>`, and a parent request that links them to the unit they describe. The map's panel shows its spend by stage from the ledger.

In our own run against a real provider (24 traces, three model facets, a small chat model and a small embedding model), Topics made 66 calls with 21,782 input and 8,779 output tokens and the ledger valued them at US$0.0065: about US$0.27 per thousand traces at list prices, with no credit for the provider's prompt-cache reads, which the shared instructions qualify for.

## Who sees what

| Permission | Lets a person | Built-in roles |
| --- | --- | --- |
| `topics:read` | See maps, topic names and descriptions, counts, figures, the scatter; use the topic term and the MCP server | Admin, Viewer, Organization admin, Team admin, Team viewer, User |
| `topics:manage` | Create and change maps, refresh, rename, merge and mute topics, write custom facets | Admin, Organization admin, Team admin |
| `topics:configure` | Change the gateway-wide settings and reset Topics | Admin |

Custom roles keep or withhold each of them. A team-scoped role sees the maps of its teams; an organization's map (one that reads every team of the organization) is created and seen by its organization admins and the gateway administrators.

- **Summary text is content.** A summary is derived from the sent view, so a route, a tool or a screen returns its text only for the teams of which the reader holds [`content_sent:read`](/docs/features/access-control/). Everyone else gets the row with `content_hidden: true`: the topic, the state and the label, never the text.
- **Topic names** are shown to `topics:read`. Two guards keep content out of them: the naming model reads summaries only and is told to use no identity, and no topic smaller than `min_topic_members` is published.
- **Organizations never mix.** A map belongs to one team or one organization; a fit reads only its own map's units; a helper call runs as the unit's own team. A team that moves to another organization leaves its maps, topics and summaries behind, like every other recorded row.

## What is stored

| What | Where | Kept |
| --- | --- | --- |
| Summary text | PostgreSQL, **encrypted** under the content key (a data key per row, bound to its unit and facet) | `retention_days`, and never longer than the content record it was read from |
| Summary state, label, embedding | PostgreSQL, in the clear (an embedding is not text, but it is derived from it) | The same |
| Topics, assignments, runs | PostgreSQL; with `spans.engine: analytics_store` the assignments are mirrored to the analytics store for the explorer | Assignments `retention_days`; a retired topic until nothing is assigned to it |

Nothing is staged outside the database. Erasing an end user removes the summaries and assignments of that user's traces and sessions. [Rotating the content key](/docs/security/keyring-rotation/) rewraps the summaries in the same `gateway content-rewrap` pass as the captured records.

## Settings

The `topics` block of the configuration file is the base. **Evals → Topics → Settings** and `PUT /api/v1/admin/topics/settings` replace the whole block at run time (the gateway administrator only); the change takes effect within one worker tick, with no restart, on every replica. `DELETE` reverts to the file. `GET` shows every field's effective value, the source (`yaml` or `api`), the embedding lock and the `version` to send back with the next `PUT` or `DELETE`: it is 0 before the first write and only grows after it (a revert takes a version too), so a write from a stale read is refused with `409 version_conflict`.

| Field | Default | Bounds | Meaning |
| --- | --- | --- | --- |
| `summary_model` | none | a chat alias | Writes the facet summaries. Required for every facet but Signals |
| `embedding_model` | none | an embeddings alias | Embeds the summaries. Locked once summaries exist |
| `embedding_dimensions` | `0` | 0, or 64 to 2048 | 0 uses the model's own size; else sent as `dimensions`. Locked with the model |
| `naming_model` | `summary_model` | a chat alias | Names topics and proposes parents |
| `readiness_idle` | `5m` | 1m to 1h | Idle time after a unit's last span before it is read |
| `refit.schedule` | `0 4 * * *` | five-field cron, UTC | When live maps are fitted again |
| `refit.window_days` | `30` | 1 to 30 | How far back a fit reads |
| `refit.min_summaries` | `100` | 10 to 100000 | Applicable summaries of a standard fit; fewer fit in small-sample mode |
| `budget_usd_per_day` | `1.00` | 0 to 100000 | Helper spend per organization and UTC day |
| `max_input_chars` | `200000` | 1000 to 2000000 | Longest transcript sent to the summary model |
| `max_maps_per_team` | `5` | 1 to 50 | Maps per team, and per organization |
| `max_topics_per_facet` | `50` | 2 to 200 | Topics a fit may publish per facet |
| `min_topic_members` | `15` | 3 to 1000 | Smallest published topic (3 in small-sample mode) |
| `retention_days` | `30` | 1 to 365 | How long summaries, embeddings and assignments are kept |
| `fit_max_summaries` | `20000` | 100 to 100000 | Summaries one fit reads; above it the newest are taken and the run says so |
| `setup_backfill` | `500` | 0 to 5000 | Recent units a new live map summarises at once |
| `snapshot_max_new_summaries` | `1000` | 0 to 5000 | Units a snapshot may summarise beyond the stored ones |
| `refresh_cooldown` | `15m` | 1m to 24h | Between two manual refreshes of a map |
| `label_split_min` | `200` | 0 to 100000 | Units of one label from which it is clustered inside; 0 never |
| `metric_topic_labels` | `0` | 0 to 50 | The topic as a metric label for the largest N topics of each facet; 0 emits none |
| `worker.interval` | `15s` | 1s to 10m | Between worker ticks |
| `worker.batch_size` | `20` | 1 to 500 | Units a map summarises per tick |
| `worker.concurrency` | `4` | 1 to 32 | Summary calls in flight |
| `findings.interval` | `15m` | 1m to 24h | Between detector passes |
| `findings.window` | `24h` | 1h to 168h | The window looked at, compared with the one before |
| `findings.min_units` | `20` | 1 or more | Units a topic needs before a finding about it |
| `findings.spike_ratio` | `2.0` | 1.1 to 100 | Growth against the previous window |
| `findings.negative_share` | `0.3` | 0 to 1 | Share of Negative sentiment |
| `findings.pass_rate_drop` | `0.2` | 0 to 1 | Absolute fall of the pass rate |
| `findings.cache_prefix_tokens` | `1024` | 64 or more | Input tokens of a prompt that should have read the prompt cache |
| `findings.large_tool_result_tokens` | `4000` | 64 or more | Input tokens one tool result adds |
| `findings.verbose_ratio` | `4.0` | 1.5 to 100 | Output length against the model's median |
| `findings.tool_error_min` | `5` | 1 or more | Failed calls of one tool |
| `findings.retry_loop_min` | `3` | 2 to 1000 | Consecutive calls of one tool in a trace |
| `findings.min_impact_usd` | `0.01` | 0 or more | Smallest spend a cost finding is raised for |
| `findings.severity` | `warning` | info, warning, critical | Severity of the alerts |
| `findings.channels` | none | up to 16 channel IDs | Alert channels that receive findings |

### Changing the embedding model

Vectors of two models cannot be compared, so the embedding model and its size are locked while embedded summaries exist: a change is refused with `embedding_locked`. To change them, reset first:

```bash
curl -X POST "$GATEWAY/api/v1/admin/topics/reset" -H "Authorization: Bearer $GATEWAY_ADMIN_TOKEN" \
  -H 'Content-Type: application/json' -d '{"confirm":"delete summaries"}'
```

The reset deletes every stored summary, topic and assignment of every team and asks each live map for a new setup. Maps, facets and settings stay.

## API

Every route takes a console session or the admin API's Bearer token.

| Route | What it does |
| --- | --- |
| `GET`, `POST /api/v1/admin/topics/maps` | List the maps you see; create a live map or a snapshot |
| `POST /api/v1/admin/topics/maps/estimate` | What a map would spend, with no model call |
| `GET`, `PATCH`, `DELETE /api/v1/admin/topics/maps/{id}` | One map with its unit counts and spend; change it, pause or resume it; delete it |
| `POST /api/v1/admin/topics/maps/{id}/refresh` | Fit a live map again now |
| `GET /api/v1/admin/topics/maps/{id}/runs` | Its fits, with what each did per facet |
| `GET /api/v1/admin/topics/maps/{id}/topics?facet=&from=&to=` | The topics of a facet with their figures |
| `GET /api/v1/admin/topics/maps/{id}/points?facet=` | The points of the scatter: each unit of the last fit with its two coordinates and its topic |
| `GET`, `PATCH /api/v1/admin/topics/{id}` | One topic; rename, describe, pin or mute it |
| `POST /api/v1/admin/topics/{id}/merge` | Move its units into another topic and retire it |
| `POST /api/v1/admin/topics/{id}/dataset`, `POST /api/v1/admin/topics/{id}/evaluator` | Fill a dataset from the topic; draft an evaluator for it |
| `GET /api/v1/admin/topics/summaries?map=&facet=&topic=` | Summaries with each unit's assignment |
| `GET /api/v1/admin/topics/assignments?map=&facet=&topic=` | Assignments, no text |
| `GET /api/v1/admin/topics/units?team=&unit=` | A trace's or a session's topics |
| `GET /api/v1/admin/topics/facets`, `PUT`, `DELETE /api/v1/admin/topics/facets/{key}` | The facets; a team's own |
| `GET /api/v1/admin/topics/findings` | The finding kinds and thresholds |
| `GET`, `PUT`, `DELETE /api/v1/admin/topics/settings`, `POST /api/v1/admin/topics/reset` | The settings; the reset |
| `POST /api/v1/admin/topics/mcp` | The MCP server |

A new map:

```bash
curl -X POST "$GATEWAY/api/v1/admin/topics/maps" -H "Authorization: Bearer $GATEWAY_ADMIN_TOKEN" -H 'Content-Type: application/json' -d '{
  "team_id": "team_support",
  "name": "Support",
  "unit": "trace",
  "filter": "model:chat* -status:error",
  "sample_rate": 0.5,
  "facets": ["intent", "sentiment", "outcome", "issues", "signals"]
}'
```

A snapshot adds `"kind": "snapshot"`, `"window_from"` and `"window_to"`. An organization's map sends `"scope": "organization"` and `"organization_id"` instead of `team_id`. A map's filter names fields of the trace itself (`model`, `status`, `session`, `duration`, `cost`, …); it takes no span field, no text search, no evaluation term and no topic term.

### MCP server

`POST /api/v1/admin/topics/mcp` is a Model Context Protocol server (Streamable HTTP, stateless: one JSON-RPC request, one JSON response) for assistants and coding agents. Point an MCP client at the URL with the admin Bearer token (`admin.token_bearer: true`) or use it from a console session. Its tools are all reads and answer exactly what the caller's own credential may read, summary text included:

`list_topic_facets`, `list_topic_maps`, `list_topics` (`map_id`, `facet`, `from`, `to`), `get_topic` (`topic_id`), `list_topic_summaries` (`map_id`, `facet`, `topic_id`, `assignment`, `limit`, `cursor`), `list_topic_assignments`.

```bash
curl -X POST "$GATEWAY/api/v1/admin/topics/mcp" -H "Authorization: Bearer $GATEWAY_ADMIN_TOKEN" -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_topics","arguments":{"map_id":"tm_0123456789abcdef","facet":"issues"}}}'
```

The console's assistant reads Topics too (`topic_maps`, `topic_facets`, `topic_findings` and `topic` among its resources).

### Commands

The `gateway` binary is also a client of a running gateway's Topics API. It reads `GATEWAY_URL` (default `http://127.0.0.1:8080`) and `GATEWAY_ADMIN_TOKEN`, never a token in an argument, and prints the API's JSON:

```bash
export GATEWAY_URL=https://gateway.example.com GATEWAY_ADMIN_TOKEN=…
gateway topics maps                          # the maps you see
gateway topics create map.json               # create a map from a JSON file (- for stdin)
gateway topics estimate map.json             # what it would spend
gateway topics topics tm_0123456789abcdef issues
gateway topics topic tp_0123456789abcdef
gateway topics summaries tm_0123456789abcdef intent tp_0123456789abcdef
gateway topics refresh tm_0123456789abcdef
gateway topics pause tm_0123456789abcdef     # and resume
gateway topics rename tp_0123456789abcdef "Data Exports"
gateway topics delete tm_0123456789abcdef
gateway topics settings | facets | findings | runs <map-id> | map <map-id>
```

Exit code 0 when done, 1 when the gateway refused or could not be reached, 2 for a usage error.

## Telemetry

- **Logs (stdout and OTLP).** `topic_assigned` for each unit placed live, with `trace_id` (or `session_id`), `map_id`, `facet`, `topic_id`, `outlier`, the team and the organization (the topic by its ID: its name, written from the units' content, stays in the API behind `topics:read`); `topics_fit` for each fit; `topics_map_paused` and `topics_budget_reached`. A topic is assigned minutes after its trace was exported, so it is a log event that carries the trace ID, not a span attribute.
- **Spans.** Each helper call is a request like any other: its own trace, its helper kind, and the unit's request as its parent.
- **Metrics.** `gateway_topics_units_total{facet,topic,origin}` and `gateway_topics_fits_total{kind,status}`. The `topic` label is `assigned` or `outlier` unless you opt in with `metric_topic_labels: N`, which names the N largest topics of each facet of each live map and folds the rest into `other`. That is up to N × facets × maps label values, and a renamed topic starts a new series, so keep N small (5 to 10) and turn it on only where those names may sit in your metrics system.

## Limits and behaviour to know

- A unit is described once per facet version. A session is summarised when it first goes idle; later traces of the same session do not change its summary.
- A unit whose content was not captured for evaluation gets no model call and is counted under `content_not_captured`; Signals still places it.
- Live assignment starts after a map's first fit. If the setup finds fewer than 10 applicable summaries the fit is skipped and the map waits for the next scheduled refit or a manual refresh.
- The scatter shows the last fit's cohort (at most 5,000 points, the newest).
- Clustering reads at most `fit_max_summaries`; a fit of 20,000 summaries of 1,024 dimensions takes 4 to 6 seconds of one core ([measured](/docs/performance/topics/)).
- Alert rules do not take topic terms; use the findings.
- Turning `topics` off stops the worker, the routes and the term at once. Stored rows stay until they expire.
