Skip to main content
You can query historical inferences to analyze model behavior, debug issues, export data for fine-tuning, and more. The TensorZero UI provides an interface to browse and filter historical inferences. You can also query historical inferences programmatically using the TensorZero Gateway.
You can find a complete runnable example of this guide on GitHub.

Query historical inferences by ID

HTTP POST /v1/inferences/get_inferences TensorZero SDK client.get_inferences(...) Retrieve specific inferences when you know their IDs.

Request

ids
string[]
required
List of inference IDs (UUIDs) to retrieve.
function_name
string
Filter by function name. Including this improves query performance since function_name is the first column in the ClickHouse primary key.
output_source
string
default:"inference"
Source of the output to return:
  • "inference": Returns the original model output
  • "demonstration": Returns human-curated feedback output (ignores inferences without one)
  • "none": Returns the inference without output
You can retrieve inferences by ID using the TensorZero Python SDK.
from tensorzero import TensorZeroGateway

t0 = TensorZeroGateway.build_http(gateway_url="http://localhost:3000")

t0.get_inferences(ids=["00000000-0000-0000-0000-000000000000"])

Response

inferences
StoredInference[]

Query historical inferences with filters

List inferences with filtering, pagination, and sorting. HTTP POST /v1/inferences/list_inferences TensorZero SDK client.list_inferences(request=ListInferencesRequest(...))

Request

after
string
Cursor pagination: get inferences after this ID (exclusive). Cannot be used with before or offset.
before
string
Cursor pagination: get inferences before this ID (exclusive). Cannot be used with after or offset.
episode_id
string
Filter by episode ID (UUID).
filters
InferenceFilter
Advanced filtering by metrics, tags, time, and demonstration feedback. Filters can be combined using logical operators (and, or, not).
function_name
string
Filter by function name.
limit
integer
default:20
Maximum number of results to return.
offset
integer
default:0
Pagination offset.
order_by
OrderBy[]
Sort criteria. You can specify multiple sort criteria.
output_source
string
default:"inference"
Source of the output to return:
  • "inference": Returns the original model output
  • "demonstration": Returns human-curated feedback output (ignores inferences without one)
  • "none": Returns the inference without output
search_query_experimental
string
Full-text search query (experimental, may cause full table scans).
variant_name
string
Filter by variant name.
You can list inferences with filters using the TensorZero Python SDK.
from tensorzero import TensorZeroGateway, ListInferencesRequest, InferenceFilterTag

t0 = TensorZeroGateway.build_http(gateway_url="http://localhost:3000")

t0.list_inferences(
    request=ListInferencesRequest(
        filters=InferenceFilterTag(
            key="my_tag",
            value="my_value",
            comparison_operator="=",
        ),
        limit=10,
    )
)

Response

inferences
StoredInference[]