Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt

Use this file to discover all available pages before exploring further.

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:
from openai import OpenAI

client = OpenAI(
    api_key="your_truefoundry_api_key",
    base_url="https://gateway.truefoundry.ai",
    default_headers={
        "X-TFY-LOGGING-CONFIG": '{"enabled": true}'
    }
)

response = client.chat.completions.create(
    model="openai-main/gpt-4",
    messages=[{"role": "user", "content": "Hello"}],
)
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

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.
ModeDescription
HEADER_CONTROLLEDLogging depends on the enabled value in the X-TFY-LOGGING-CONFIG header. If the header is absent or set to true, logging will occur. If set to false, no logging will happen.
ALWAYSAll requests are logged regardless of the enabled value.
NEVERNo requests are logged regardless of the enabled value.

Viewing Request Logs

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

Data Access Rules for Request Logs and Metrics

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