The TensorZero Gateway stores inference and feedback data in ClickHouse. This data can be used for observability, experimentation, and optimization.

ChatInference

The ChatInference table stores information about inference requests for Chat Functions made to the TensorZero Gateway. A ChatInference row can be associated with one or more ModelInference rows, depending on the variant’s type. For chat_completion, there will be a one-to-one relationship between rows in the two tables. For other variant types, there might be more associated rows.
ColumnTypeNotes
idUUIDMust be a UUIDv7
function_nameString
variant_nameString
episode_idUUIDMust be a UUIDv7
inputString (JSON)input field in the /inference request body
outputString (JSON)Array of content blocks
tool_paramsString (JSON)Object with any tool parameters (e.g. tool_choice, tools_available) used for the inference
inference_paramsString (JSON)Object with any inference parameters per variant type (e.g. {"chat_completion": {"temperature": 0.5}})
processing_time_msUInt32
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"user_id": "123"})

JsonInference

The JsonInference table stores information about inference requests for JSON Functions made to the TensorZero Gateway. A JsonInference row can be associated with one or more ModelInference rows, depending on the variant’s type. For chat_completion, there will be a one-to-one relationship between rows in the two tables. For other variant types, there might be more associated rows.
ColumnTypeNotes
idUUIDMust be a UUIDv7
function_nameString
variant_nameString
episode_idUUIDMust be a UUIDv7
inputString (JSON)input field in the /inference request body
outputString (JSON)Object with parsed and raw fields
output_schemaString (JSON)Schema that the output must conform to
inference_paramsString (JSON)Object with any inference parameters per variant type (e.g. {"chat_completion": {"temperature": 0.5}})
processing_time_msUInt32
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"user_id": "123"})

ModelInference

The ModelInference table stores information about each inference request to a model provider. This is the inference request you’d make if you had called the model provider directly.
ColumnTypeNotes
idUUIDMust be a UUIDv7
inference_idUUIDMust be a UUIDv7
raw_requestStringRaw request as sent to the model provider (varies)
raw_responseStringRaw response from the model provider (varies)
model_nameStringName of the model used for the inference
model_provider_nameStringName of the model provider used for the inference
input_tokensNullable(UInt32)
output_tokensNullable(UInt32)
response_time_msNullable(UInt32)
ttft_msNullable(UInt32)Only available in streaming inferences
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
systemNullable(String)The system input to the model
input_messagesArray(RequestMessage)The user and assistant messages input to the model
outputArray(ContentBlock)The output of the model
A RequestMessage is an object with shape {role: "user" | "assistant", content: List[ContentBlock]} (content blocks are defined here).

DynamicInContextLearningExample

The DynamicInContextLearningExample table stores examples for dynamic in-context learning variants.
ColumnTypeNotes
idUUIDMust be a UUIDv7
function_nameString
variant_nameString
namespaceString
inputString (JSON)
outputString
embeddingArray(Float32)
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)

BooleanMetricFeedback

The BooleanMetricFeedback table stores feedback for metrics of type = "boolean".
ColumnTypeNotes
idUUIDMust be a UUIDv7
target_idUUIDMust be a UUIDv7 that is either inference_id or episode_id depending on level in metric config
metric_nameString
valueBool
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"author": "Alice"})

FloatMetricFeedback

The FloatMetricFeedback table stores feedback for metrics of type = "float".
ColumnTypeNotes
idUUIDMust be a UUIDv7
target_idUUIDMust be a UUIDv7 that is either inference_id or episode_id depending on level in metric config
metric_nameString
valueFloat32
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"author": "Alice"})

CommentFeedback

The CommentFeedback table stores feedback provided with metric_name of "comment". Comments are free-form text feedbacks.
ColumnTypeNotes
idUUIDMust be a UUIDv7
target_idUUIDMust be a UUIDv7 that is either inference_id or episode_id depending on level in metric config
target_type"inference" or "episode"
valueString
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"author": "Alice"})

DemonstrationFeedback

The DemonstrationFeedback table stores feedback in the form of demonstrations. Demonstrations are examples of good behaviors.
ColumnTypeNotes
idUUIDMust be a UUIDv7
inference_idUUIDMust be a UUIDv7
valueStringThe demonstration or example provided as feedback (must match function output)
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
tagsMap(String, String)User-assigned tags (e.g. {"author": "Alice"})

ModelInferenceCache

The ModelInferenceCache table stores cached model inference results to avoid duplicate requests.
ColumnTypeNotes
short_cache_keyUInt64First part of composite key for fast lookups
long_cache_keyFixedString(64)Hex-encoded 256-bit key for full cache validation
timestampDateTimeWhen this cache entry was created, defaults to now()
outputStringThe cached model output
raw_requestStringRaw request that was sent to the model provider
raw_responseStringRaw response received from the model provider
is_deletedBoolSoft deletion flag, defaults to false
The table uses the ReplacingMergeTree engine with timestamp and is_deleted columns for deduplication. It is partitioned by month and ordered by the composite cache key (short_cache_key, long_cache_key). The short_cache_key serves as the primary key for performance, while a bloom filter index on long_cache_key helps optimize point queries.

ChatInferenceDataset

The ChatInferenceDataset table stores chat inference examples organized into datasets.
ColumnTypeNotes
dataset_nameLowCardinality(String)Name of the dataset this example belongs to
function_nameLowCardinality(String)Name of the function this example is for
idUUIDMust be a UUIDv7, often the inference ID if generated from an inference
episode_idUUIDMust be a UUIDv7
inputString (JSON)input field in the /inference request body
outputNullable(String) (JSON)Array of content blocks
tool_paramsString (JSON)Object with any tool parameters (e.g. tool_choice, tools_available) used for the inference
tagsMap(String, String)User-assigned tags (e.g. {"user_id": "123"})
auxiliaryStringAdditional JSON data (unstructured)
is_deletedBoolSoft deletion flag, defaults to false
updated_atDateTimeWhen this dataset entry was updated, defaults to now()
The table uses the ReplacingMergeTree engine with updated_at and is_deleted columns for deduplication. It is ordered by dataset_name, function_name, and id to optimize queries filtering by dataset and function.

JsonInferenceDataset

The JsonInferenceDataset table stores JSON inference examples organized into datasets.
ColumnTypeNotes
dataset_nameLowCardinality(String)Name of the dataset this example belongs to
function_nameLowCardinality(String)Name of the function this example is for
idUUIDMust be a UUIDv7, often the inference ID if generated from an inference
episode_idUUIDMust be a UUIDv7
inputString (JSON)input field in the /inference request body
outputString (JSON)Object with parsed and raw fields
output_schemaString (JSON)Schema that the output must conform to
tagsMap(String, String)User-assigned tags (e.g. {"user_id": "123"})
auxiliaryStringAdditional JSON data (unstructured)
is_deletedBoolSoft deletion flag, defaults to false
updated_atDateTimeWhen this dataset entry was updated, defaults to now()
The table uses the ReplacingMergeTree engine with updated_at and is_deleted columns for deduplication. It is ordered by dataset_name, function_name, and id to optimize queries filtering by dataset and function.

BatchRequest

The BatchRequest table stores information about batch requests made to model providers. We update it every time a particular batch_id is created or polled.
ColumnTypeNotes
batch_idUUIDMust be a UUIDv7
idUUIDMust be a UUIDv7
batch_paramsStringParameters used for the batch request
model_nameStringName of the model used
model_provider_nameStringName of the model provider
statusStringOne of: ‘pending’, ‘completed’, ‘failed’
errorsArray(String)Array of error messages if status is ‘failed’
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)
raw_requestStringRaw request sent to the model provider
raw_responseStringRaw response received from the model provider
function_nameStringName of the function being called
variant_nameStringName of the function variant

BatchModelInference

The BatchModelInference table stores information about inferences made as part of a batch request. Once the request succeeds, we use this information to populate the ChatInference, JsonInference, and ModelInference tables.
ColumnTypeNotes
inference_idUUIDMust be a UUIDv7
batch_idUUIDMust be a UUIDv7
function_nameStringName of the function being called
variant_nameStringName of the function variant
episode_idUUIDMust be a UUIDv7
inputString (JSON)input field in the /inference request body
systemStringThe system input to the model
input_messagesArray(RequestMessage)The user and assistant messages input to the model
tool_paramsString (JSON)Object with any tool parameters (e.g. tool_choice, tools_available) used for the inference
inference_paramsString (JSON)Object with any inference parameters per variant type (e.g. {"chat_completion": {"temperature": 0.5}})
raw_requestStringRaw request sent to the model provider
model_nameStringName of the model used
model_provider_nameStringName of the model provider
output_schemaStringOptional schema for JSON outputs
tagsMap(String, String)User-assigned tags (e.g. {"author": "Alice"})
timestampDateTimeMaterialized from id (using UUIDv7ToDateTime function)