Workflows

Orchestrate complex multi-step AI operations with workflows.

What Are Workflows?

Workflows are multi-step AI orchestrations that chain multiple capabilities together. They're perfect for complex operations that require multiple AI calls in sequence.

For example, a workflow might:

  1. Generate an image from a prompt
  2. Enrich the image with tags and captions
  3. Moderate the content for safety
  4. Store the results
  5. Send a webhook notification

When to Use Workflows vs Direct API Calls

Use Workflows When:

  • You need to chain multiple AI operations
  • Operations depend on previous step results
  • You want automatic error handling and retries
  • You need async execution (don't want to wait)
  • You want execution history and debugging

Use Direct API Calls When:

  • You need a single, simple operation
  • You want synchronous results immediately
  • You don't need complex orchestration

Workflow Structure

Workflows are defined as JSON configurations with:

  • Steps - Array of operations to execute
  • Step dependencies - Control execution order
  • Input mapping - Map workflow input to step inputs
  • Error handling - Retry logic and failure behavior

Workflows are versioned per app and can be slug-based (predefined) or ephemeral (plan-based).

Execution Lifecycle

Workflows execute asynchronously using Kafka-based workers:

  1. You create a workflow run via API
  2. Workflow run is created in database (status: pending)
  3. First step is enqueued to Kafka
  4. Worker consumes step and executes it
  5. Step result is stored, next step is enqueued
  6. Process repeats until workflow completes or fails

You can poll for status or set up webhooks to be notified of completion.

Step Types

Common step types include:

  • image_generate - Generate images
  • text_generate - Generate text
  • enrich_text - Enrich text content
  • enrich_image - Enrich image content
  • moderate_content - Moderate content
  • search_similar - Vector similarity search
  • store_results - Store artifacts
  • emit_webhook - Send webhook notifications

Creating a Workflow Run

POST /v1/workflows/run

curl -X POST https://api.whizur.com/v1/workflows/run \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "your-app-id",
    "workflowSlug": "image-generate-v1",
    "input": {
      "prompt": "A beautiful sunset",
      "size": "1024x1024"
    }
  }'

Response includes a statusUrl to poll for completion.

Polling for Status

Use the statusUrl from the workflow run response to check status:

GET /v1/workflows/runs/:runId

Status values: pending, running, completed, failed

Webhooks

Configure webhooks to receive notifications when workflows complete or fail. Webhooks are sent to your specified URL with workflow run details.

Next Steps