Workflow as an API
Workflow APIs work the same way as other model endpoints, you can simply send a request and get a response back. However, it is common for workflows to contain multiple steps and produce intermediate results, as each step contains their own response that could be relevant in your use-case. Therefore, workflows benefit from the streaming feature, which allows you to get partial results as they are being generated.Workflow events
The workflow API will trigger a few events during its execution, these events can be used to monitor the progress of the workflow and get intermediate results. Below are the events that you can expect from a workflow stream:The submit event
This events is triggered every time a new step has been submitted to execution. It contains the app_id, request_id and the node_id.
The completion event
This event is triggered upon the completion of a specific step.
The output event
The output event means that the workflow has completed and the final result is ready.
The error event
The error event is triggered when an error occurs during the execution of a step. The error object contains the error.status with the HTTP status code, an error message as well as error.body with the underlying error serialized.
Example
A cool and simple example of the power of workflows isworkflows/fal-ai/sdxl-sticker, which consists of three steps:
1
Generates an image using 
fal-ai/fast-sdxl.2
Remove the background of the image using 
fal-ai/imageutils/rembg.3
Converts the image to a sticker using 
fal-ai/face-to-sticker.- Javascript
- python
- python (async)
- Swift