Skip to main content
TrueFoundry AI Gateway allows you to control which requests are logged.

Controlling Request Logging

Using HTTP Headers

Include the X-TFY-LOGGING-CONFIG header on a request with a stringified JSON value. Set enabled to true to log the request or false to skip logging:
Note that the value of X-TFY-LOGGING-CONFIG is a stringified JSON, not a raw JSON object. Most SDKs serialize headers as strings, so wrap the JSON in quotes as shown above.

Using Global Settings

Global logging settings are being deprecated. Use Logging Configuration instead. It lets you control logging per subject, model, MCP server, or metadata and redact sensitive values. Global settings continue to work during the transition but will be removed after three months. See Migrating to logging configs.
You can also control logging behavior globally using AI Gateway global settings:
In the AI Gateway UI, click Settings in the left sidebar to open global settings.

Migrating to logging configs

Logging Configuration replaces the global logging modes with rule-based control:

Payload Size Limit for Traces

TrueFoundry AI Gateway caps the size of input and output span attributes recorded on gateway requests. When a payload exceeds the cap, it is replaced with a skip marker instead of being stored. You can configure this cap using the TFY_TRACE_MAX_PAYLOAD_SIZE environment variable on the AI Gateway. It defines the maximum number of characters allowed for input/output span attributes on a gateway request before they are replaced with a skip marker.
Increase this value only if you need full payloads in traces for larger requests. Larger values increase storage and may affect trace ingestion and query performance.

Enabling Distributed Tracing

  • How it works: propagate trace context with the W3C traceparent header; the gateway reads tracestate to keep parent-child links when a request leaves the gateway and circles back (e.g. an LLM/tool calling back into the gateway), then generates spans and pushes them to the OpenTelemetry Collector.
  • Enable: set ENABLE_DISTRIBUTED_TRACING=true on tfy-llm-gateway (defaults to false).
We recommend using ordered (time-sortable) trace IDs (for example UUIDv7 or ULID) when generating trace IDs in your instrumentation. Ordered trace IDs improve query performance, which directly affects the load times of the Metrics and Traces pages in the TrueFoundry UI and the latency of fetching metrics and traces through the APIs.

Viewing Request Logs

You can view all logged requests in the TrueFoundry UI. Go to AI Gateway > Monitor > Requests

Request logs in the Monitor section

Data Access Rules for Request Logs and Metrics

Please refer to Data Access Rules for Traces and Metrics for more information.