Skip to main content

SDK Streaming

Streaming improves user trust by showing progress during long-running actions.

Step 1: Start an Operation

Create a run or long task using the SDK.

const run = await client.runs.create({ projectId, goal: "Generate release notes" });

Step 2: Subscribe to Progress Events

const stream = client.runs.stream(run.id);

for await (const event of stream) {
console.log(event.type, event.data);
}

Step 3: Render Progress in UI

  1. Show current status.
  2. Append intermediate output as it arrives.
  3. Mark completion or failure explicitly.

Step 4: Handle Interruptions

  • Reconnect when network drops.
  • Guard against duplicate event rendering.
  • Persist final status server-side.

Step 5: Close the Loop

On completion, refresh related project data and store final artifacts.