Skip to main content
The LLM Gateway delivers detailed request logs through tracing. Retrieve these logs using the Query Spans API.
To better understand tracing concepts like traces, spans, and how they work together, see our tracing overview.

Contents

SectionDescription
OverviewQuickstart with SDK and HTTP API
Trace inspectionInspect a single trace and span hierarchy
FilteringFilter request logs
Basic queriesTime range, users, virtual accounts
Advanced queriesTrace ID, model spans, metadata, MCP
Span attributesAttribute reference

Quickstart

Setup the TrueFoundry SDK

To start querying request logs, install and configure the TrueFoundry SDK and CLI.
Follow the CLI Setup Guide for installation instructions and authentication steps.
Once setup is complete, you can use the SDK to query tracing data programmatically.

Fetch using TrueFoundry SDK

Each request to the LLM Gateway generates a trace—a timeline of everything that happened, from the incoming request to guardrails to the model call and any external APIs. Let’s pull the latest Gateway traces and see real data quickly.Fetch the latest LLM Gateway request logs:
You can get the tracing_project_fqn from the Fetch via API button on the Request Logs page
from truefoundry import client

# Fetch LLM Gateway request logs
spans = client.traces.query_spans(
    data_routing_destination="default",
    start_time="2025-01-21T00:00:00.000Z",
)

for span in spans:
    print(span.span_name, span.span_attributes.get('tfy.span_type'))