Skip to main content

Experiment

Object-centric interface for Galileo experiments. An experiment represents a systematic evaluation framework for running controlled tests on datasets to measure and compare AI model performance.

Important Notes

Two-Phase Execution: Experiments are created in two phases:
  1. Create the experiment metadata (name, dataset, optional prompt)
  2. Run the experiment by creating a job that executes on the dataset
This allows you to set up the experiment structure before execution. Prompt Settings Hierarchy: When running an experiment with a prompt template, the prompt_settings parameter passed to run() completely overrides any settings stored in the prompt template itself. The Runners service uses ONLY the settings provided at job creation time. If you don’t provide prompt_settings to run(), default values will be used. To use the template’s settings, retrieve them first using get_prompt_template_settings() and pass them explicitly. Experiment Immutability: Once an experiment has been run and has traces, it cannot be run again. To re-run with the same configuration, create a new experiment with a different name. This ensures experiment results remain comparable and auditable. Dataset Requirements: While dataset is optional during creation, it is required when running the experiment with either a prompt template or a function. Examples

add_tag

Add a tag to this experiment. Tags can be used to categorize, filter, and organize experiments. Common use cases include environment labels, version tracking, and team ownership. Arguments
  • key (str): Tag key (e.g., “environment”, “version”, “team”)
  • value (str): Tag value (e.g., “production”, “1.0.0”, “ml-team”)
  • tag_type (str): Tag category, defaults to “generic”. Other options: “rag”

aggregate_metrics

Get computed aggregate metrics for this experiment. Returns aggregate metrics like average_cost, average_latency, total_responses, and quality metrics (e.g., average_factuality, average_correctness). Note: Call refresh() first to get the latest metric values after experiment completion. Examples

create

Persist this experiment to the API. Examples

dataset

Get the dataset associated with this experiment.

delete

Delete this experiment. This is a destructive operation that permanently removes the experiment and all associated data (traces, spans, metrics, results) from the API. WARNING: This operation cannot be undone! After successful deletion, the object state is set to DELETED. The local object still exists in memory but no longer represents a remote resource. Examples

experiment_columns

Get available metric columns for this experiment. Returns a :class:~galileo.shared.column.ColumnCollection of all columns available in the experiment comparison table. Scorer-backed metric columns carry UUID-based IDs of the form "metrics/{scorer-uuid}", which map directly to the keys returned by

export_records

Export records from this experiment. Arguments
  • record_type: The type of records to export (SPAN, TRACE, or SESSION).
  • filters: A list of filters to apply to the export.
  • sort: A sort clause to order the exported records.
  • export_format: The desired format for the exported data.
  • column_ids: A list of column IDs to include in the export.
  • redact: Redact sensitive data from the response.

get

Get an existing experiment by name. Arguments
  • name (str): The experiment name.
  • project_id (Optional[str]): The project ID. If neither project_id nor project_name is provided, falls back to GALILEO_PROJECT_ID or GALILEO_PROJECT environment variables.
  • project_name (Optional[str]): The project name. If neither project_id nor project_name is provided, falls back to GALILEO_PROJECT environment variable.

get_metric_aggregate

Return aggregate statistics for a specific metric. Looks up a metric by any of the following identifiers, tried in order:
  1. :class:~galileo.schema.metrics.GalileoMetrics enum value — its value IS the human-readable label (e.g. GalileoMetrics.correctness"Correctness").
  2. Scorer UUID string — direct lookup in :attr:metric_aggregates, no column resolution needed.
  3. Human-readable label string (e.g. "Correctness") — resolved via :attr:experiment_columns.
  4. Legacy metric_key_alias string (e.g. "correctness") — fallback after label matching fails.
Returns None if :attr:metric_aggregates is not yet populated (metrics still computing) or the metric is not found. Arguments
  • metric: Any of: a :class:GalileoMetrics enum value, scorer UUID string, human-readable label, or legacy metric_key_alias.
Returns
  • MetricAggregates | None: Aggregate stats with avg, min_, max_, p50, p90, p95, p99, count, and value_distribution fields; or None if not available.
Examples

get_prompt_template_settings

Get the settings from the associated prompt template. WARNING: These settings are NOT automatically used when running the experiment. The Runners service ignores template settings and only uses the prompt_settings passed to the run() method. Use this method to retrieve template settings if you want to apply them to the job. Examples

get_sessions

Query sessions in this experiment. This is a convenience method that queries for sessions specifically. Arguments
  • filters: A list of filters to apply to the query.
  • sort: A sort clause to order the query results.
  • limit: The maximum number of records to return.
  • starting_token: The token for the next page of results.

get_spans

Query spans in this experiment. This is a convenience method that queries for spans specifically. Arguments
  • filters: A list of filters to apply to the query.
  • sort: A sort clause to order the query results.
  • limit: The maximum number of records to return.
  • starting_token: The token for the next page of results.

get_status

Get the current status of this experiment in human-readable format. Examples

get_traces

Query traces in this experiment. This is a convenience method that queries for traces specifically. Arguments
  • filters: A list of filters to apply to the query.
  • sort: A sort clause to order the query results.
  • limit: The maximum number of records to return.
  • starting_token: The token for the next page of results.

has_traces

Check if this experiment has any traces. Experiments with traces cannot have new jobs created on them. To re-run an experiment, create a new experiment with a different name. Examples

is_winner

Check if this experiment is marked as the winner. The winner is the best-performing experiment in a set of comparisons, typically the one with rank=1 and the highest ranking score. Examples

list

List all experiments for a project. Arguments
  • project_id (Optional[str]): The project ID. If neither project_id nor project_name is provided, falls back to GALILEO_PROJECT_ID or GALILEO_PROJECT environment variables.
  • project_name (Optional[str]): The project name. If neither project_id nor project_name is provided, falls back to GALILEO_PROJECT environment variable.

metric_aggregates

Get structured aggregate metrics for this experiment, keyed by metric identifier. Returns full statistical aggregates (avg, min, max, sum, count, p50, p90, p95, p99, value_distribution) for each metric.

Key types

  • UUID keys (36-char strings, e.g. "550e8400-e29b-41d4-a716-446655440000") — scorer-backed metrics. The UUID matches column.id.removeprefix("metrics/") for the corresponding entry in :attr:experiment_columns.
  • Raw-string keys (e.g. "cost", "duration_ns") — system metrics computed without a scorer. These do not appear in :attr:experiment_columns.

Resolving UUIDs to human labels

Use :attr:experiment_columns to look up the display label and legacy metric name for each UUID:
The MetricAggregates object exposes: avg, min_, max_, sum_, count, pct, p50, p90, p95, p99, value_distribution. For boolean metrics, value_distribution holds {"0": count_false, "1": count_true}. Note: Call :meth:refresh first to get the latest values after experiment completion. Examples

model

Get the Model object for this experiment. Returns the Model if it was set during initialization, otherwise attempts to create a basic Model representation from the model_alias. Examples

monitor_progress

Monitor the progress of the experiment job with a progress bar. Arguments
  • job_id: Optional job ID to monitor. If not provided, will attempt to find the primary job for this experiment.

playground_name

Get the name of the playground this experiment was created from, if any.

Returns

str | None: Playground name if this is a playground experiment, None otherwise.

project

Get the project this experiment belongs to.

prompt

Get the prompt template associated with this experiment. Note: For playground-created experiments that haven’t been run yet, the prompt information may not be available automatically. In such cases, use set_prompt() to manually set the prompt before running the experiment.

prompt_model

Get the model used in the prompt for this experiment. This is the model alias that was configured in the prompt settings when the experiment was run (e.g., “Claude 3.5 Haiku”, “GPT-4o”). Examples

query

Query records in this experiment. This method provides a convenient way to search spans, traces, or sessions within the current experiment results. Arguments
  • record_type: The type of records to query (SPAN, TRACE, or SESSION).
  • filters: A list of filters to apply to the query.
  • sort: A sort clause to order the query results.
  • limit: The maximum number of records to return.
  • starting_token: The token for the next page of results.

rank

Get the rank of this experiment compared to others in the project. Lower rank number means better performance. Rank 1 is the best-performing experiment. Ranking is calculated based on aggregate metrics and quality scores. Examples

ranking_score

Get the ranking score for this experiment. This score is used to compare experiments. Higher scores indicate better performance. The score is calculated based on a combination of quality metrics and efficiency metrics. Examples

refresh

Refresh this experiment’s state from the API. Updates all attributes with the latest values from the remote API and sets the state to SYNCED. Examples

run

Returns the experiment run result. The experiment is triggered during create() via trigger=True. This method exists for backward compatibility with the create().run() call pattern.

Returns

ExperimentRunResult: Result object with link and status.

Raises

ValueError: If the experiment has not been created yet.

session_columns

Get available columns for sessions in this experiment. Examples

set_prompt

Set or update the prompt for this experiment. This is useful for experiments created in the playground where prompt information may not be automatically retrieved from the API. Arguments
  • prompt: Prompt object, prompt name, or PromptTemplate object.
  • prompt_name: Name of the prompt template (alternative to prompt parameter).
  • prompt_id: ID of the prompt template (alternative to prompt parameter).

span_columns

Get available columns for spans in this experiment. Examples

tags

Get tags associated with this experiment. Tags are organized by category (e.g., “generic”, “rag”). Each category contains a list of tag objects with key, value, and metadata. Examples

trace_columns

Get available columns for traces in this experiment. Examples