Streaming
Streaming simulation via Server-Sent Events
Run a simulation and receive progressive results via Server-Sent Events.
The connection stays open and emits events as the Mojo engine computes:
- progress events every checkpoint_every runs (default: 1000) Each carries Welford online statistics: mean, std, min, max, probability_of_loss, runs_completed, progress (0–1).
- final event when complete — contains the full DecisionEnvelope identical to what /v1/simulate returns.
Example (curl)
curl -N -X POST /v1/simulate/stream \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{"mode":"expert","runs":100000,"variables":[...]}'
Example (JavaScript EventSource)
const es = new EventSource('/v1/simulate/stream?token=sk-...');
es.addEventListener('progress', e => console.log(JSON.parse(e.data)));
es.addEventListener('final', e => {
console.log(JSON.parse(e.data).result);
es.close();
});
Query parameters
- checkpoint_every — emit a progress event every N runs (default: 1000, min: 100)
post/v1/simulate/stream
Request
- Base URL: https://api.algenta.ai
- URL: https://api.algenta.ai/v1/simulate/stream
- Auth: one of:
- HTTP bearer
- API key in header X-API-Key
Query parameters
checkpoint_everyinteger
Request body
Example request
{
"mode": "auto",
"runs": 10000,
"scenario": {
"name": "Product launch decision",
"objective": "maximize_net_value",
"variables": {
"cost": {
"high": 90000,
"low": 40000
},
"revenue": {
"high": 200000,
"low": 80000
}
}
},
"simulation_model": "monte_carlo"
}Response
SSE stream of progress events + final DecisionEnvelope
Changes
No recorded changes to this operation across all 1 revision of this API.