Experiment
Package experiments is A/B testing anything: a flag, an ad, a subject line, a model.
Package experiments is A/B testing anything: a flag, an ad, a subject line, a model.
| Base URL | https://api.hanzo.ai |
| Operations | 7 |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Specification
Specification pending — no HIP in hanzoai/hips declares capability: experiment yet. What this capability serves is below, from the API document; what it is — the store it owns, how it meters, what it publishes — is written as a HIP under HIP-0139.
Four surfaces
| Surface | Reaches this capability as | Coverage |
|---|---|---|
| REST | experiment at its own prefix | 7 operations |
| CLI | hanzo experiments … | 7 of 7 |
| SDK | — | no published client declares one yet — regenerating the clients is what adds them |
| MCP | tool experiments on https://api.hanzo.ai/v1/mcp | 7 operations, 2 under the document's own id — ask describe for the rest |
Quickstart
export HANZO_API_KEY=sk-... # console.hanzo.ai → API keysThen the first call — a read that needs nothing but the key. GET /v1/experiment, operation get_experiment:
hanzo experiments listimport { Configuration, ExperimentApi } from 'hanzoai';
const api = new ExperimentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getExperiment();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import ExperimentApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ExperimentApi(client).get_experiment()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.ExperimentAPI.GetExperiment(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, experiment_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = experiment_api::get_experiment(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.ExperimentApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new ExperimentApi(client).getExperiment();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
curl https://api.hanzo.ai/v1/experiment \
-H "Authorization: Bearer $HANZO_API_KEY"Tool experiments, op get_experiment — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "experiments",
"arguments": {
"op": "get_experiment",
"input": {}
}
}
}'Answers 200 with object — ok.
Endpoints
| Endpoint | What it does |
|---|---|
POST /v1/experiment/{id}/analyze | Is per-variant conversion, lift and statistical significance against the control arm. |
GET /v1/experiment/{id}/assign | Is the variant one subject is bucketed into, and the payload that variant carries. |
POST /v1/experiment/{id}/decide | Promotes one variant to the whole rollout and records who decided. |
GET /v1/experiment/{id} | Is one experiment's definition and lifecycle: variants, weights, control arm, status and winner. |
GET /v1/experiment/health | Is whether the experiments subsystem is mounted and serving in this process. |
GET /v1/experiment | Is every experiment in the caller's org, with its variants, status and decision, ordered by project then id. |
POST /v1/experiment | Registers a controlled experiment AND puts its assignment flag live, in that order, so the arms start bucketing subjects the moment this returns 201… |
How is this guide?