Queue endpoints
The queue functionality is exposed via standardized per-model paths underhttps://queue.fal.run.
| Endpoint | Method | Description |
|---|---|---|
https://queue.fal.run/{model_id} | POST | Adds a request to the queue for a top-level path |
https://queue.fal.run/{model_id}/{subpath} | POST | Adds a request to the queue for an optional subpath |
https://queue.fal.run/{model_id}/requests/{request_id}/status | GET | Gets the status of a request |
https://queue.fal.run/{model_id}/requests/{request_id}/status/stream | GET | Streams the status of a request until it’s completed |
https://queue.fal.run/{model_id}/requests/{request_id} | GET | Gets the response of a request |
https://queue.fal.run/{model_id}/requests/{request_id}/cancel | PUT | Cancels a request that has not started processing |
model_id: the model ID consists of a namespace and model name separated by a slash, e.g.fal-ai/fast-sdxl. Many models expose only a single top-level endpoint, so you can directly call them bymodel_id.subpath: some models expose different capabilities at different sub-paths, e.g.fal-ai/flux/dev. The subpath (/devin this case) should be used when making the request, but not when getting request status or resultsrequest_idis returned after adding a request to the queue. This is the identifier you use to check the status and get results and logs
Submit a request
Here is an example of using curl to submit a request which will add it to the queue:request_id:
request_id, and provides you with the necessary information to get the status of your request, cancel it or get the response once it’s ready, so you don’t have to build these endpoints yourself.
Object Lifecycle
You can control how long images and other objects generated by your request remain available by including theX-Fal-Object-Lifecycle-Preference header. This header allows you to specify the expiration duration for objects created during the request processing.
The header value must be a JSON object with an expiration_duration_seconds field specifying the number of seconds the objects should remain available:
Object LifecycleThe
X-Fal-Object-Lifecycle-Preference header applies to all objects (images, files, etc.) generated during request processing. If you need different expiration times for different requests, you can include this header with each request.Request status
Once you have the request id you may use this request id to get the status of the request. This endpoint will give you information about your request’s status, it’s position in the queue or the response itself if the response is ready.IN_QUEUE status:
Status types
Queuestatus can have one of the following types and their respective properties:
-
IN_QUEUE(and status code 202):queue_position: The current position of the task in the queue.response_url: The URL where the response will be available once the task is processed.
-
IN_PROGRESS(and status code 202):logs: An array of logs related to the request. Note that it needs to be enabled, as explained in the next section.response_url: The URL where the response will be available.
-
COMPLETED(and status code 200):logs: An array of logs related to the request. Note that it needs to be enabled, as explained in the next section.response_url: The URL where the response is available.
Logs
Logs are disabled by default. In order to enable logs for your request, you need to send thelogs=1 query parameter when getting the status of your request. For example:
logs attribute in the queue status contains an array of log entries, each represented by the RequestLog type. A RequestLog object has the following attributes:
message: a string containing the log message.level: the severity of the log, it can be one of the following:STDERR|STDOUT|ERROR|INFO|WARN|DEBUG
source: indicates the source of the log.timestamp: a string representing the time when the log was generated.
Streaming status
If you want to keep track of the status of your request in real-time, you can use the streaming endpoint. The response istext/event-stream and each event is a JSON object with the status of the request exactly as the non-stream endpoint.
This endpoint will keep the connection open until the status of the request changes to COMPLETED.
It supports the same logs query parameter as the status.
Cancelling a request
If your request has not started processing (status isIN_QUEUE), you may attempt to cancel it.
202 Accepted response with the following body:
400 Bad Request response with this body:
Getting the response
Once you get theCOMPLETED status, the response will be available along with its logs.
The HTTP status code you get is typically the HTTP status code that was returned by the model. This way you can differentiate success (200) vs model error (5XX) vs invalid request (4XX). There are 2 exceptions:
404if the request cannot be found400if the request has not been completed
COMPLETED status:
A simple queue recipeSubmit your request and let our client handle the status tracking for you. The next section details how the fal client simplifies building apps with fal functions.