Creating a run
| Argument | Type | Default | Description |
|---|---|---|---|
prompt | string | required | The instruction for the run. |
template | Template | 'auto' | Canvas template. See Templates. |
blocks | BlockType[] | undefined | Allow-list of block types the run may produce. |
agent_instructions | string | undefined | Extra system-prompt instructions for the agent. |
webhook_url | string | undefined | Reserved for future webhook delivery. |
files | FileInput[] | undefined | Files to upload — see below. |
runs.create returns a CreatedRun holding run_id, status
(always 'running'), poll_url, and estimated_duration_ms.
Passing blocks: [] is rejected client-side with
SpineBadRequestError — omit the field entirely to use the template
default.
Uploading files
The SDK normalises several shapes so you can mix them freely:File objects directly. Supported file types and size limits are
documented on File uploads.
Waiting for completion
client.runs.waitForCompletion() polls the server until the run reaches
a terminal state (completed, partial, or failed), then returns the
terminal Run:
| Option | Default | Notes |
|---|---|---|
pollIntervalMs | 5000 | Delay between polls in milliseconds. |
timeoutMs | 900_000 (15 min) | Throws SpineTimeoutError if exceeded. |
signal | — | AbortSignal for cooperative cancellation. |
resolveOnFailure | false | If true, resolves with the failed run instead of throwing. |
'failed' terminal state throws SpineRunFailedError.
Partial successes return normally — some blocks succeeded, some
failed; inspect terminal.errors on the returned object.
Cancellation
Narrowing the result
The returnedRun is a discriminated union on status. Narrow before
accessing state-specific fields:
Manual polling
If you want full control — custom cadence, streaming progress to a UI, non-standard backoff — callclient.runs.retrieve() directly: