Overview
This page explains how to use Basalt’s Experiments API with Python. Experiments help you organize, track, and compare different approaches in your AI workflows.Installation
Ensure you have the Basalt SDK installed:Client Initialization
Access the experiments API through theexperiments property on the main Basalt client:
Creating Experiments
You can create experiments programmatically to register new tests or variants.Synchronous Creation
Asynchronous Creation
Using Experiments with Observability
The most common use case is attaching an experiment context to your traces. This allows you to slice and dice your observability data by experiment.Experiments in a Loop
When processing multiple items under one experiment, eachstart_observe() call
naturally creates a separate trace — the context manager cleans up the
OpenTelemetry context on exit, so the next iteration starts fresh.