- A TensorZero function (“task”)
 - A set of candidate variants (prompts, models, etc.) to experiment with
 - A metric to optimize for
 
See the Tutorial to learn more about functions and variants in TensorZero.
Configure
Let’s set up an adaptive A/B test with TensorZero.You can find a complete runnable example of this guide on GitHub.
1
Configure your function
Let’s configure a function (“task”) with two variants (
gpt-5-mini with two different prompts), a metric to optimize for, and the experimentation configuration.tensorzero.toml
2
Deploy TensorZero
You must set up Postgres to use TensorZero’s automated experimentation features.
3
Make inference requests
Make an inference request just like you normally would and keep track of the inference ID or episode ID.
You can use the TensorZero Inference API or the OpenAI-compatible Inference API.
4
Send feedback for your metric
Send feedback for your metric and assign it to the inference ID or episode ID.
5
Track your experiment
That’s it.
TensorZero will automatically adjust the distribution of inference requests between the two candidate variants based on their performance.You can track the experiment in the TensorZero UI.
Visit the function’s detail page to see the variant weights and the estimated performance.If you run the code example, TensorZero starts by splitting traffic between the two variants but quickly starts shifting more and more traffic towards the 
 You can add more variants at any time and TensorZero will adjust the experiment accordingly in a principled way.
gpt-5-mini-good-prompt variant.
After a few hundred inferences, TensorZero becomes confident enough to declare it the winner and starts serving all the traffic to it.
Advanced
Configure fallback-only variants
In addition tocandidate_variants, you can also specify fallback_variants in your configuration.
If a variant fails for any results, TensorZero first resamples from candidate_variants.
Once they are exhausted, it samples from fallback_variants with uniform probability.
See the Configuration Reference for more details.
Customize the experimentation algorithm
Thetrack_and_stop algorithm has multiple parameters that can be customized.
For example, you can trade off the speed of the experiment with the statistical confidence of the results.
The default parameters are sensible for most use cases, but advanced users might want to customize them.
See the Configuration Reference for more details.