Workflows

View Markdown

Overview

A workflow defines the sequence of tasks that will be executed. Workflows are used in both Runs (via POST /runs) and Automations (as the workflow array).

Each step in the workflow represents a task — such as transcoding video, generating subtitles, or analyzing content.


Structure

A workflow is an array of task definitions. Each task includes:

PropertyDescription
kindThe type of task (e.g. video, image, summary, subtitles, speech)
optionsTask-specific options (e.g. format, width, height, quality)
metadataOptional key-value pairs to attach to the task (e.g. { "ref": "poster" })
nextAn optional array of tasks to run after this task completes

Parallel execution

Tasks at the same level in the array run in parallel:

{
  "workflow": [
    { "kind": "summary" },
    { "kind": "image", "options": { "width": 320, "format": "png" } },
    { "kind": "subtitles" }
  ]
}

All three tasks start at the same time.


Sequential chaining

Use the next field to run tasks after a parent task completes:

{
  "workflow": [
    {
      "kind": "video",
      "options": { "width": 1280, "format": "mp4", "quality": "high" },
      "next": [
        { "kind": "image", "options": { "width": 640, "format": "jpeg" } },
        { "kind": "subtitles" }
      ]
    }
  ]
}

Here the video transcode runs first, then the thumbnail and subtitles are generated from the output in parallel.


Conditional branches

Use the conditions kind to conditionally run tasks based on input file properties:

{
  "workflow": [
    { "kind": "summary" },
    {
      "kind": "conditions",
      "options": {
        "kind": { "eq": "video" }
      },
      "next": [
        { "kind": "subtitles" },
        { "kind": "chapters" }
      ]
    },
    {
      "kind": "conditions",
      "options": {
        "width": { "gt": 1920 }
      },
      "next": [
        {
          "kind": "video",
          "options": { "width": 1920, "format": "mp4" }
        }
      ]
    }
  ]
}

Conditions evaluate properties of the input file using operator-as-key syntax:

OperatorDescriptionExample
eqEqual to{ "kind": { "eq": "video" } }
notNot equal to{ "kind": { "not": "audio" } }
gtGreater than{ "width": { "gt": 1920 } }
gteGreater than or equal{ "duration": { "gte": 60 } }
ltLess than{ "filesize": { "lt": 10000000 } }
lteLess than or equal{ "height": { "lte": 720 } }
inValue is in array{ "format": { "in": ["mp4", "webm"] } }
startsWithString starts with{ "mimetype": { "startsWith": "video/" } }
endsWithString ends with{ "filename": { "endsWith": ".mp4" } }

Complete example

{
  "name": "Video Processing Pipeline",
  "description": "Full processing pipeline for video uploads",
  "workflow": [
    { "kind": "summary" },
    { "kind": "speech" },
    {
      "kind": "conditions",
      "options": {
        "kind": { "eq": "video" }
      },
      "next": [
        {
          "kind": "video",
          "options": { "width": 1280, "format": "mp4", "quality": "high" },
          "next": [
            { "kind": "image", "options": { "width": 640, "format": "jpeg" } }
          ]
        },
        { "kind": "subtitles" },
        { "kind": "chapters" },
        { "kind": "thumbnails" }
      ]
    }
  ],
  "status": "active"
}

This automation:

  1. Generates a summary and transcribes speech for all uploads (in parallel)
  2. For video files only: creates a 720p version, then extracts a thumbnail from it
  3. For video files only: generates subtitles, chapters, and thumbnails in parallel

On this page