> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.aiplanet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage and cost

> Query usage records, token counts, estimated cost, latency, and optional retained payloads.

Usage records always contain request metadata, key/application attribution, requested and resolved models, provider, status, token counts, estimated cost, latency, and streaming state. Prompt and response bodies are stored only when deployment-owned `data_governance.payload_storage` is explicitly enabled.

## Summary

```bash theme={null}
curl -sS \
  "$GATEWAY_ADMIN_URL/admin/usage?app_id=invoice-agent&environment=prod" \
  -H "Authorization: Bearer $GATEWAY_ADMIN_KEY"
```

Summary fields are `requests`, `error_requests`, input/output/total tokens, `estimated_cost`, `average_latency_ms`, and `costed_requests`.

## Filters

Usage, breakdown, time-series, and recent-request endpoints support relevant combinations of:

* `start_at` and `end_at` ISO-8601 timestamps;
* `api_key_id`;
* `org_id`;
* `app_id`;
* `environment`;
* `model`;
* `provider`;
* `status_code`.

## Breakdown

```bash theme={null}
curl -sS \
  "$GATEWAY_ADMIN_URL/admin/usage/breakdown?dimension=model&limit=20" \
  -H "Authorization: Bearer $GATEWAY_ADMIN_KEY"
```

Dimensions are `model`, `provider`, `api_key`, `org`, `app`, `environment`, and `status`.

## Time series

```bash theme={null}
curl -sS \
  "$GATEWAY_ADMIN_URL/admin/usage/timeseries?interval=day&environment=prod" \
  -H "Authorization: Bearer $GATEWAY_ADMIN_KEY"
```

Intervals are `hour` and `day`.

## Recent requests

```bash theme={null}
curl -sS \
  "$GATEWAY_ADMIN_URL/admin/requests?api_key_id=invoice-agent-prod&limit=50&offset=0" \
  -H "Authorization: Bearer $GATEWAY_ADMIN_KEY"
```

The response includes `total`, `limit`, `offset`, and `has_more`. Advance `offset` by `limit` to page through the filtered result. Request logs additionally accept `outcome=success|denied|error` and a literal substring search over request/session IDs through `q` (maximum 128 characters).

Request logs are buffered and retried outside the inference response path. A prolonged database outage can drop metadata records; monitor `gateway_request_logs_dropped_total`. Budget enforcement uses a separate transactional ledger and remains authoritative for admission.

List rows include `payload_available` and `payload_truncated` but never inline the bodies. When available, fetch one exchange through the tenant-scoped detail endpoint:

```bash theme={null}
curl -sS \
  "$GATEWAY_ADMIN_URL/admin/requests/REQUEST_ID" \
  -H "Authorization: Bearer $GATEWAY_ADMIN_KEY"
```

The detail includes `request_payload`, `response_payload`, and `payload_captured_at`. Credential-bearing keys and gateway token patterns are redacted, but ordinary PII and customer content remain visible. See [Data retention and privacy](/llm-gateway/operations/data-retention) before enabling capture.
