Inference Logoinference.sh

Flow Runs

Execute saved flows programmatically and track multi-step orchestration runs.

Requires API key scopes flows:read (list, get, stream), flows:execute (create, cancel), or flows:write (update, visibility, clone). Create keys in Settings → API Keys.

Flows concept — how flows chain apps and relate to tasks


Create flow run

POST /flowruns

Starts a new run of a saved flow. Requires flows:execute.

Request

FieldTypeRequiredDescription
flowstringYesFlow ID
inputobjectYesFlow inputs (shape depends on the flow definition)

Example:

json
1{2  "flow": "flow_abc123",3  "input": {4    "prompt": "A mountain landscape"5  }6}

Response

Returns a FlowRun object. Key fields:

FieldTypeDescription
idstringFlow run ID
flow_idstringSource flow ID
flow_version_idstringFlow version used for this run
task_idstringParent task ID (tracks the full run in Tasks)
statusnumberFlow run status code (see below)
inputobjectInputs passed to the run
outputobjectFinal output when complete
node_tasksobjectPer-node task references (task_id, nested task)
errorstringError message when failed
flow_run_startedstringISO timestamp when execution began
flow_run_finishedstringISO timestamp when execution completed

Example:

bash
1curl -X POST https://api.inference.sh/flowruns \2  -H "Authorization: Bearer inf_your_key" \3  -H "Content-Type: application/json" \4  -H "X-API-Version: 2" \5  -d '{"flow":"flow_abc123","input":{"prompt":"A mountain landscape"}}'

JavaScript SDK

typescript
1const run = await client.flowRuns.create('flow_abc123', { prompt: 'A mountain landscape' });2console.log(run.task_id, run.status);

The Python SDK does not yet expose flowRuns; use the REST call above.


Get flow run

GET /flowruns/{id}

Returns a single flow run by ID. Same fields as create response.

bash
1curl https://api.inference.sh/flowruns/flowrun_abc123 \2  -H "Authorization: Bearer inf_your_key" \3  -H "X-API-Version: 2"

List flow runs

POST /flowruns/list

Cursor-paginated list. Requires flows:read.

GET /flowruns is also available with the same scope.

FieldTypeDescription
limitnumberPage size
cursorstringCursor from a previous response
filtersarrayFilter objects (field, operator, value)
sortarraySort objects (field, dir)

Cancel flow run

POST /flowruns/{id}/cancel

Stops an in-progress flow run. Requires flows:execute.

bash
1curl -X POST https://api.inference.sh/flowruns/flowrun_abc123/cancel \2  -H "Authorization: Bearer inf_your_key" \3  -H "X-API-Version: 2"

Clone flow from a run

POST /flowruns/{id}/clone

Creates a new flow definition copied from the flow version used in this run. Returns a Flow object (not a new run). Requires flows:write.

Use this to fork a flow after iterating in the editor or from a successful run.


Update flow run

POST /flowruns/{id}

Patch flow run metadata. Requires flows:write.

POST /flowruns/{id}/visibility updates sharing visibility.


Stream updates

Real-time SSE for flow run state and per-step tasks.

EndpointScopeDescription
GET /flowruns/{id}/streamflows:readFlow run status and output updates
GET /flowruns/{id}/tasks/streamflows:readTask updates for nodes in this run

Send Accept: text/event-stream and X-API-Version: 2. Event format matches Task streaming.

JavaScript SDK

typescript
1const source = client.flowRuns.stream('flowrun_abc123');2const taskSource = client.flowRuns.streamTasks('flowrun_abc123');

Streaming API


Flow run status codes

Flow runs use a separate status enum from task status codes.

StatusCodeDescription
Unknown0Unrecognized status
Pending1Starting
Running2Executing steps
Completed3Done
Failed4Error occurred
Cancelled5Cancelled

The parent task_id on the flow run tracks overall progress in the Tasks API and workspace UI.


Tasks API — parent task status, logs, cost, cancellation
Flows — visual editor, deploying flows as apps
REST overview — authentication and API versioning

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.