Create and submit experiments to Gentrace with experiment()
experiment()
function to submit an experiment to Gentrace. It manages the lifecycle of a Gentrace experiment, automatically starting and finishing the experiment while providing context for evaluation functions like eval()
/ evalOnce()
and evalDataset()
/ eval_dataset()
.
experiment()
function is designed to work with
evaluation functions. To fully understand how to use experiments
effectively, you should also review: - eval()
/
evalOnce()
- For running individual test cases -
evalDataset()
/ eval_dataset()
- For batch
evaluation against datasets These functions must be called within an
experiment context to properly track and group your test results.pipeline_id
parameter is omitted, the experiment will automatically submit to the default pipeline. In Python, use @experiment
without parentheses when no parameters are provided. In TypeScript, use experiment(async () => { ... })
. This is convenient for quick testing, but we recommend explicitly specifying the pipeline ID for production use.experiment()
function:
experiment()
function manages the experiment lifecycle automatically:
Start
Context
Execution
Finish
Error
objects (TypeScript) and exceptions (Python) are automatically captured as span eventsERROR
when unhandled exceptions occurinit()
with a valid API key. The SDK automatically configures OpenTelemetry for you. For custom OpenTelemetry setups, see the manual setup guideinit()
- Initialize the Gentrace SDKinteraction()
- Instrument AI functions for tracing within experimentsevalDataset()
/ eval_dataset()
- Run tests against a dataset within an experimentevalOnce()
/ eval()
- Run individual test cases within an experimenttraced()
- Alternative approach for tracing functions