client.run()
starts a task, polls until it finishes, and returns the output.
Install
Client
High-level
client.run(prompt, opts) returns a RunHandle that is both awaitable (resolves to a
RunResult) and async-iterable (yields live messages). After iterating, read
run.result.
RunOptions
RunResult
{ taskId, status, task, output, rows }. output is the flattened rows
({ field: value }), or validated objects when schema is set. rows is the raw rows
including sources and metadata.
Output rows come back as “cell” objects: each field is { value, source_id } plus
metadata like _sources. output flattens these for you; use rows for the provenance.
Resources
Attach a CSV
files.upload() runs the whole three-call upload for you: it creates a task if you do not
pass taskId, presigns, PUTs the bytes without your API key attached, and validates.
attached carries the validated shape — filename, rows, fields, renamed,
delimiter, and extra_columns. Pass { content, filename } instead of a path to upload
from memory. Accepts .csv, .txt, .md, .markdown up to 10 MB / 10,000 rows.
Errors
OutOfCreditsError → 402, TaskExecutingError → 409, AuthenticationError → 401,
TaskNotFoundError → 404, RunTimeoutError when run() exceeds its timeout.
Terminal state
A finished task returns tostatus: "plan" with activity: "idle". Use the exported
isTerminal(task) rather than checking status directly. run() already does.