Skip to main content
Requires Node.js 18 or newer for global fetch.

Polling

The choice handler picks the first option. Replace it with your own logic. To stop a task early, api("POST", "/abort", { sessionId }).

Uploading a file

Streaming

For a long-lived process, read the SSE body directly.
Answer approvals on the streaming path with POST /approve from another request; the stream stays open while it waits.