DocumentationUsage Guide

Usage Guide

Create runs, poll for status, stream events, and use webhooks.

Basic Flow

  1. 1.Create a run - POST /api/v1/tasks/runs with prompt and model
  2. 2.Poll or stream - Use run_id to get status, output, or stream events
  3. 3.Retrieve result - When status is succeeded or failed, get output

Polling for Status

bash
curl -H "x-api-key: sk-flow-YOUR_KEY" \
  https://<your-domain>/api/v1/tasks/runs/run_abc123

Long-Poll for Result

GET /api/v1/tasks/runs/{run_id}/result?timeout=60 waits until the run completes or times out:

bash
curl -H "x-api-key: sk-flow-YOUR_KEY" \
  "https://<your-domain>/api/v1/tasks/runs/run_abc123/result?timeout=60"

Streaming Events (SSE)

GET /api/v1/tasks/runs/{run_id}/events returns a Server-Sent Events stream:

bash
curl -N -H "x-api-key: sk-flow-YOUR_KEY" \
  -H "Accept: text/event-stream" \
  https://<your-domain>/api/v1/tasks/runs/run_abc123/events

Events include task.status, task.agent.text-delta, task.done, etc.

Webhooks

Pass webhook_url when creating a run. When the run completes, we POST a payload to that URL. Must use HTTPS; no private IPs.