SDK Essentials
Patterns that apply across every resource in the SDK.
Pagination
List methods return one page: an object with data and nextCursor. nextCursor is null on the last page. To walk every page, use iter, an async generator that fetches each next page for you.
Every resource exposes both list and iter.
Streaming
Run events and activity expose a streamUrl that returns a server-sent events endpoint. Consume it with any SSE client:
Errors
The SDK throws typed errors. Catch the base class, or narrow to a specific one:
The controller-busy case has a dedicated helper:
Idempotency
Billable POSTs - starting a runtime, creating an invocation, exporting run files - accept an idempotency key so a retried request does not run twice:
A replayed key returns the original result rather than creating a duplicate.
Schema authoring
Invocations that extract structured data accept a Zod schema as schema. The SDK converts it to JSON Schema on the wire and validates the output:
Pass schema, not outputSchema - the latter is the wire field the SDK produces for you.
Next
- Runs - what streaming subscribes to
- Invocations - where schemas are used
- API Reference - status codes and error shapes

