Application Process
To use the API, you need to first apply for the corresponding service on the Flux Images Generation API page. After entering the page, click the “Acquire” button, as shown in the image below:
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.
Upon your first application, there will be a free quota available for you to use the API for free.
Basic Usage
First, understand the basic usage method, which involves inputting the promptprompt, the action action, and the image size size to obtain the processed result. You first need to simply pass a field action with the value generate, and then we also need to input the prompt, as detailed below:

accept: the format of the response result you want to receive, here filled in asapplication/json, which means JSON format.authorization: the key to call the API, which can be directly selected after application.
action: the action of this image generation task.size: the size of the generated image result.count: the number of images to generate, with a default value of 1; this parameter is only valid for image generation tasks and is invalid for editing tasks.prompt: the prompt.model: the generation model, default isflux-dev.callback_url: the URL to receive the callback result.
size has some special restrictions, mainly divided into two types: width x height aspect ratio and x:y image ratio, as detailed below:
| Model | Range |
|---|---|
| flux-2-flex | Supports aspect ratio x >= 64 must be a multiple of 32 |
| flux-2-pro | Supports aspect ratio x >= 64 must be a multiple of 32 |
| flux-2-max | Supports aspect ratio x >= 64 must be a multiple of 32 |
| flux-pro-1.1 | Supports aspect ratio 256 <= x <= 1440 must be a multiple of 32 |
| flux-dev | Supports aspect ratio 256 <= x <= 1440 must be a multiple of 32 |
| flux-pro-1.1-ultra | Does not support aspect ratio supports image ratio |
| flux-kontext-pro | Does not support aspect ratio supports image ratio |
| flux-kontext-max | Does not support aspect ratio supports image ratio |

success, the status of the image generation task at this time.task_id, the ID of the image generation task at this time.trace_id, the tracking ID of the image generation at this time.data, the result list of the image generation task at this time.image_url, the link to the image generation task at this time.prompt, the prompt.
data result.
Additionally, if you want to generate the corresponding integration code, you can directly copy the generated code, for example, the CURL code is as follows:
Editing Image Tasks
If you want to edit a specific image, the parameterimage_url must first be passed with the link to the image that needs to be edited, at this time action only supports edit, and you can specify the following content:
- model: the model used for this image editing task, which currently supports
flux-kontext-max,flux-kontext-pro. - image_url: the link to the image that needs to be uploaded for editing.


Asynchronous Callback
Due to the relatively long generation time of the Flux Images Generation API, which takes about 1-2 minutes, if the API does not respond for a long time, the HTTP request will keep the connection open, leading to additional system resource consumption. Therefore, this API also provides support for asynchronous callbacks. The overall process is as follows: when the client initiates a request, an additionalcallback_url field is specified. After the client makes the API request, the API will immediately return a result containing a task_id field, representing the current task ID. When the task is completed, the result of the generated image will be sent to the callback_url specified by the client in the form of a POST JSON, which also includes the task_id field, allowing the task result to be associated by ID.
Let’s understand how to operate specifically through an example.
First, the Webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For demonstration purposes, we use a public Webhook sample site https://webhook.site/, where you can obtain a Webhook URL as shown in the image:
Copy this URL, and it can be used as a Webhook. The sample here is https://webhook.site/3d32690d-6780-4187-a65c-870061e8c8ab.
Next, we can set the callback_url field to the above Webhook URL and fill in the corresponding parameters, as shown in the image:

https://webhook.site/3d32690d-6780-4187-a65c-870061e8c8ab, as shown in the image:
The content is as follows:
task_id field, and the other fields are similar to the above, allowing the task to be associated through this field.
Error Handling
When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:400 token_mismatched: Bad request, possibly due to missing or invalid parameters.400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.401 invalid_token: Unauthorized, invalid or missing authorization token.429 too_many_requests: Too many requests, you have exceeded the rate limit.500 api_error: Internal server error, something went wrong on the server.

