05

Runs and streaming

Core platform1 min read

Create, observe, cancel, resume, and replay durable agent runs.

MethodEndpointPurpose
POST/v1/runsCreate an idempotent run
GET/v1/runs/{run_id}Read current run state
GET/v1/runs/{run_id}/eventsStream resumable SSE events
POST/v1/runs/{run_id}/cancelCancel work across service boundaries
GET/v1/runs/{run_id}/artifactsList generated artifacts
Create and stream a run
const run = await client.createRun({  prompt: 'Research Base liquidity and produce a report',  idempotencyKey: crypto.randomUUID(),});const stop = client.streamRunEvents(run.runId, (event, frame) => {  console.log(frame.sequenceId, event.type);}, { lastEventId: 0 });

Resume safely

Persist the last SSE sequence and reconnect with Last-Event-ID. Reuse the original idempotency key when retrying run creation after a timeout.

Was this page helpful?

Edit on GitHub