Run a workflow

Start a workflow run, watch it finish, and download the audio — in Python or the CLI.

A run executes a workflow’s pipeline and produces audio. Start a run, poll until it’s done, then download the result.

Start and watch a run

1import time
2from onepin import OnepinClient
3
4client = OnepinClient()
5
6run = client.workflows.runs.start(workflow_id).data
7while run.status not in ("completed", "failed", "cancelled"):
8 time.sleep(3)
9 run = client.workflows.runs.status(workflow_id, run.id).data
10 print(run.status, f"{run.finished_steps or 0}/{run.total_steps or 0}")
11
12if run.status != "completed":
13 raise RuntimeError(f"run {run.status}: {run.error}")

There are no completion webhooks yet — polling is the way. Short scripts finish in seconds.

Download the result

A completed run’s export is a ZIP of the audio files plus a manifest.csv. The download URL is pre-signed and valid for 15 minutes.

1import httpx
2
3dl = client.workflows.download_run(workflow_id, run.id).data
4resp = httpx.get(dl.url)
5resp.raise_for_status()
6with open(dl.filename, "wb") as f:
7 f.write(resp.content)

Only completed runs are downloadable — active, failed, or cancelled runs return 409, and a run with no audio returns 404.

List workflows and run history

1for wf in client.workflows.list(limit=50).data:
2 print(wf.id, wf.name)
3
4for r in client.workflows.runs.list(workflow_id, limit=20).data:
5 print(r.id, r.status, r.created_at)