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:
- Generate an image from a prompt
- Enrich the image with tags and captions
- Moderate the content for safety
- Store the results
- 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:
- You create a workflow run via API
- Workflow run is created in database (status: pending)
- First step is enqueued to Kafka
- Worker consumes step and executes it
- Step result is stored, next step is enqueued
- 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 imagestext_generate- Generate textenrich_text- Enrich text contentenrich_image- Enrich image contentmoderate_content- Moderate contentsearch_similar- Vector similarity searchstore_results- Store artifactsemit_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.
