> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fabricgateway.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fabricgateway.ai/_mcp/server.

# LLM Observability plugin

> Reference for the LLM Observability plugin, which records token usage, model, and finish reason for every LLM request.

The LLM Observability plugin reads the token usage, response model, and finish reason from each LLM answer that carries them. An OpenAI chat stream carries usage only when the client sets `stream_options.include_usage`, and answers over 10 MiB aren't read. For each LLM request, it writes one `llm.complete` log line on the data plane and, when metering is on and the data plane has a usage writer, one usage record. Other plugins, such as [LLM Rate Limit](/reference/plugins/llm-rate-limit), use the token counts it records.

## Where it runs

|             |                                                                                                                   |
| ----------- | ----------------------------------------------------------------------------------------------------------------- |
| Protocols   | LLM routes. On MCP and A2A requests it writes a log line with no provider, model, or tokens, and no usage record. |
| Scope kinds | `global` only                                                                                                     |
| Phase       | Request, each stream chunk, and after the response                                                                |

Your organization can have one instance, and it must be named `llm-observability`. Attaching it to a route, connection, or consumer is rejected.

## Configuration

Each field overrides the data plane's default for requests that the instance applies to.

| Field                     | Type    | Default                     | Description                                                                                     |
| ------------------------- | ------- | --------------------------- | ----------------------------------------------------------------------------------------------- |
| `log_request`             | boolean | `false`                     | Adds the request body to the `llm.complete` log line.                                           |
| `log_response`            | boolean | `false`                     | Adds the response body to the `llm.complete` log line.                                          |
| `log_stream`              | boolean | `false`                     | Writes one `llm.stream_chunk` log line per stream event.                                        |
| `max_body_bytes`          | integer | `4096` (data plane setting) | The maximum size of a logged body.                                                              |
| `capture_message_content` | boolean | `false`                     | Keeps streamed bytes and assembles the streamed reply. Non-streamed answers are always decoded. |
| `max_payload_bytes`       | integer | `16384`                     | The maximum stream bytes kept when `capture_message_content` is on.                             |

> **Warning**
>
> Logged bodies can contain prompts and personal data. Add the [PII Redaction](/reference/plugins/pii-redaction) plugin to scrub them, or leave body logging off.

## Example

```json
{
  "name": "llm-observability",
  "plugin_id": "llm-observability",
  "scope": { "kind": "global" },
  "config": { "log_request": false, "log_response": false }
}
```

## Related guides

* [Review analytics](/use/monitor/analytics)
* [Monitor gateway traffic](/use/monitor)