Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions flux/docs/flux_images_generation_api_integration_guide.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# Flux Images Generation API Integration Instructions
---
title: "Flux Images Generation API Integration Instructions"
description: "Flux Image Generation integration guide - Ace Data Cloud"
---

This article will introduce the integration instructions for the Flux Images Generation API, which can generate official Flux images by inputting custom parameters.

## Application Process

To use the API, you need to first apply for the corresponding service on the [Flux Images Generation API](https://platform.acedata.cloud/documents/6b9197c5-7a3f-4878-a43f-7f94e7e66394) page. After entering the page, click the "Acquire" button, as shown in the image below:
To use Flux Images Generation API, first open the [Ace Data Cloud Console](https://platform.acedata.cloud/console/applications) and copy your API Token.

![](https://cdn.acedata.cloud/q6ytrc.png)
![](https://cdn.acedata.cloud/5hmkdg.jpg)

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.
If you are not logged in, you will be redirected to sign in and brought back to this page automatically.

Upon your first application, there will be a free quota available for you to use the API for free.
**A single API Token works across every service on the platform — no need to subscribe per service.** New accounts receive free starter credit; when it runs low you can top up your shared balance in the [console](https://platform.acedata.cloud/console/coin).

> 📘 Full documentation: [Flux Images Generation API →](https://platform.acedata.cloud/documents/flux-images)

## Basic Usage

First, understand the basic usage method, which involves inputting the prompt `prompt`, 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:

<p><img src="https://cdn.acedata.cloud/wz85jt.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/wz85jt.png" width="500" className="m-auto" /></p>

Here we can see that we have set the Request Headers, including:

Expand All @@ -39,15 +44,19 @@ The parameter `size` has some special restrictions, mainly divided into two type
| 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-dev | Supports aspect ratio 256 <= x <= 1440 must be a multiple of 32 |
| flux-pro-1.1 | Supports aspect ratio 256 &lt;= x &lt;= 1440 must be a multiple of 32 |
| flux-dev | Supports aspect ratio 256 &lt;= x &lt;= 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 |

Reference image ratios: "1:1", "16:9", "21:9", "3:2", "2:3", "4:5", "5:4", "3:4", "4:3", "9:16", "9:21",

After selection, the corresponding code is generated on the right side. Before copying it, confirm that the authorization header uses your own API key; real credentials must never appear in documentation or screenshots.
After selection, you can see that the corresponding code is also generated on the right side, as shown in the image below:

<p><img src="https://cdn.acedata.cloud/8q7aux.png" width="500" className="m-auto" /></p>

Click the "Try" button to test, and we get the following result:
Click the "Try" button to test, as shown in the image above, and we get the following result:

```json
{
Expand All @@ -57,12 +66,12 @@ Click the "Try" button to test, and we get the following result:
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://fal.media/files/lion/NVhtlwwGYQD6HrGaEfrzu_341484fad6d84b21b73f4f8824a3f98a.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-001",
"timings": 1752743801
},
{
"prompt": "a white siamese cat",
"image_url": "https://fal.media/files/monkey/8UEQpFbQCYVOK1wKP3aV0_9bbc26fad64049b18d0244b99ef66ad1.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-002",
"timings": 1752743801
}
]
Expand Down Expand Up @@ -104,11 +113,11 @@ If you want to edit a specific image, the parameter `image_url` must first be pa

An example of the input is as follows:

<p><img src="https://cdn.acedata.cloud/jn9da5.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/jn9da5.png" width="500" className="m-auto" /></p>

After filling in, the code is automatically generated as follows:

<p><img src="https://cdn.acedata.cloud/6cwxb8.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/6cwxb8.png" width="500" className="m-auto" /></p>

The corresponding code:

Expand Down Expand Up @@ -144,7 +153,7 @@ Clicking run, you can find that you will immediately get a result, as follows:
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://fal.media/files/monkey/aEUXJZ6Faj9YXUCQVs01Q_af0cea56c558441c9ba8df67b200812d.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-001",
"timings": 1752744073
}
]
Expand All @@ -168,7 +177,7 @@ Copy this URL, and it can be used as a Webhook. The sample here is `https://webh

Next, we can set the `callback_url` field to the above Webhook URL and fill in the corresponding parameters, as shown in the image:

<p><img src="https://cdn.acedata.cloud/wm6caw.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/wm6caw.png" width="500" className="m-auto" /></p>

Clicking run, you will immediately receive a result as follows:

Expand All @@ -192,7 +201,7 @@ The content is as follows:
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://sf-maas-uat-prod.oss-cn-shanghai.aliyuncs.com/outputs/f4f8d407-377a-408a-82d0-427a5a836f09_0.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-001",
"seed": 1698551532,
"timings": {
"inference": 3.328
Expand Down Expand Up @@ -229,4 +238,4 @@ When calling the API, if an error occurs, the API will return the corresponding

## Conclusion

Through this document, you have learned how to use the Flux Images Generation API to generate images by inputting prompts. We hope this document helps you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.
Through this document, you have learned how to use the Flux Images Generation API to generate images by inputting prompts. We hope this document helps you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.
69 changes: 39 additions & 30 deletions flux/docs/flux_tasks_api_integration_guide.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
# Integration and Use of Flux Tasks API
---
title: "Integration and Use of Flux Tasks API"
description: "Flux Image Generation integration guide - Ace Data Cloud"
---

The main function of the Flux Tasks API is to query the execution status of tasks by inputting the task ID generated by the Flux Images Generation API.

This document will provide detailed integration instructions for the Flux Tasks API, helping you easily integrate and fully utilize the powerful features of this API. With the Flux Tasks API, you can easily query the execution status of tasks from the Flux Images Generation API.

## Application Process

To use the Flux Tasks API, you first need to apply for the corresponding service on the application page [Flux Images Generation API](https://platform.acedata.cloud/documents/6b9197c5-7a3f-4878-a43f-7f94e7e66394), and then copy the task ID from the Flux Images Generation API, as shown in the image below:
To use the Flux Images Generation API, first obtain your API Token from the [Ace Data Cloud Console](https://platform.acedata.cloud/console/applications) for future reference.

<p><img src="https://cdn.acedata.cloud/7furhb.png" width="500" class="m-auto"></p>
![](https://cdn.acedata.cloud/5hmkdg.jpg)

Finally, go to the Flux Tasks API page [Flux Tasks API](https://platform.acedata.cloud/documents/39b38bbe-60f3-40da-b2b6-5ce1e091852b) to apply for the corresponding service. 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 to invite you to register and log in, and after completion, you will be automatically returned to the current page.

![Application Page](https://cdn.acedata.cloud/rci31i.png)
**One API Token can call all services on the platform without needing to apply separately for each service.** The first application will grant a free quota for a trial experience; when the quota is insufficient, you can recharge the general balance in the [console](https://platform.acedata.cloud/console/coin).

If you are not logged in or registered, you will be automatically redirected to the [login page](https://platform.acedata.cloud) inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.

There is a free quota available for first-time applicants, allowing you to use this API for free.
> 📘 Complete Documentation: [Flux Images Generation API →](https://platform.acedata.cloud/documents/flux-images)

## Request Example

The Flux Tasks API can be used to query the results of the Flux Images Generation API. For information on how to use the Flux Images Generation API, please refer to the documentation [Flux Images Generation API](https://platform.acedata.cloud/documents/flux-images-integration).

We will use a task ID returned by the Flux Images Generation API service as an example to demonstrate how to use this API. Suppose we have a task ID: 2db0168c-2373-4367-8d9a-9dc778802e8a, and we will demonstrate how to pass in a task ID.
We will demonstrate how to use this API with an example task ID returned by the Flux Images Generation API. Suppose we have a task ID: 2db0168c-2373-4367-8d9a-9dc778802e8a, we will demonstrate how to pass in a task ID.

### Task Example Image

<p><img src="https://cdn.acedata.cloud/7furhb.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/7furhb.png" width="500" className="m-auto" /></p>

### Setting Request Headers and Request Body

**Request Headers** include:

- `accept`: Specifies that the response should be in JSON format, set to `application/json`.
- `accept`: Specifies that the response result should be in JSON format, set to `application/json`.
- `authorization`: The key to call the API, which can be selected directly after application.

**Request Body** includes:
Expand All @@ -42,13 +43,13 @@ We will use a task ID returned by the Flux Images Generation API service as an e

Set as shown in the image below:

<p><img src="https://cdn.acedata.cloud/fiasxz.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/fiasxz.png" width="500" className="m-auto" /></p>

### Code Example

You can see that various language codes have been automatically generated on the right side of the page, as shown in the image below:
You can see that various language codes have been automatically generated on the right side of the page, as shown in the image:

<p><img src="https://cdn.acedata.cloud/j6gn86.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/j6gn86.png" width="500" className="m-auto" /></p>

Some code examples are as follows:

Expand Down Expand Up @@ -89,7 +90,7 @@ print(response.text)

### Response Example

Upon a successful request, the API will return the detailed information of the image task here. For example:
Upon successful request, the API will return the detailed information of the image task here. For example:

```json
{
Expand All @@ -98,6 +99,9 @@ Upon a successful request, the API will return the detailed information of the i
"api_id": "deefc5d7-7f22-43e9-929e-f2b6afee60b7",
"application_id": "001c2f84-2a4a-4c4d-ba3f-8a89f43b5be2",
"created_at": 1736304669.779,
"started_at": 1736304669.839,
"finished_at": 1736304679.439,
"elapsed": 9.6,
"credential_id": "b00bddd3-140f-4343-a9a2-affb312b60de",
"request": {
"action": "generate",
Expand All @@ -113,7 +117,7 @@ Upon a successful request, the API will return the detailed information of the i
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://sf-maas-uat-prod.oss-cn-shanghai.aliyuncs.com/outputs/57d9ff7c-5a00-409e-9dcc-90f35b38d16e_0.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-001",
"seed": 281520112,
"timings": {
"inference": 3.193
Expand All @@ -124,36 +128,40 @@ Upon a successful request, the API will return the detailed information of the i
}
```

The returned result contains multiple fields, with the request field being the request body when the task was initiated, and the response field being the response body returned after the task is completed. The field descriptions are as follows.
The returned result contains multiple fields, the request field is the request body when the task was initiated, while the response field is the response body returned after the task is completed. The field descriptions are as follows.

- `id`: The ID of the image task generated, used to uniquely identify this image generation task.
- `request`: The request information in the image task.
- `response`: The return information in the image task.
- `created_at`: The task creation time, Unix timestamp (seconds, float).
- `started_at`: The task start execution time, Unix timestamp (seconds, float).
- `finished_at`: The task completion time, Unix timestamp (seconds, float). This field is not returned if the task is not completed.
- `elapsed`: The time taken for task execution, in seconds (float, rounded to 3 decimal places). This field is not returned if the task is not completed.

## Batch Query Operation

This is for querying the details of multiple task IDs, and unlike the above, the action needs to be selected as retrieve_batch.

**Request Body** includes:

- `ids`: An array of uploaded task IDs.
- `ids`: The array of uploaded task IDs.
- `action`: The operation method for the task.

Set as shown in the image below:

<p><img src="https://cdn.acedata.cloud/k3i9ns.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/k3i9ns.png" width="500" className="m-auto" /></p>

### Code Example

You can see that various language codes have been automatically generated on the right side of the page, as shown in the image below:
You can see that various language codes have been automatically generated on the right side of the page, as shown in the image:

<p><img src="https://cdn.acedata.cloud/pt5fww.png" width="500" class="m-auto"></p>
<p><img src="https://cdn.acedata.cloud/pt5fww.png" width="500" className="m-auto" /></p>

Some code examples are as follows:

### Response Example

Upon a successful request, the API will return the specific details of all batch image tasks this time. For example:
Upon successful request, the API will return the specific details of all batch image tasks this time. For example:
```json
{
"items": [
Expand All @@ -163,6 +171,9 @@ Upon a successful request, the API will return the specific details of all batch
"api_id": "deefc5d7-7f22-43e9-929e-f2b6afee60b7",
"application_id": "001c2f84-2a4a-4c4d-ba3f-8a89f43b5be2",
"created_at": 1736304669.779,
"started_at": 1736304669.839,
"finished_at": 1736304679.439,
"elapsed": 9.6,
"credential_id": "b00bddd3-140f-4343-a9a2-affb312b60de",
"request": {
"action": "generate",
Expand All @@ -178,7 +189,7 @@ Upon a successful request, the API will return the specific details of all batch
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://sf-maas-uat-prod.oss-cn-shanghai.aliyuncs.com/outputs/57d9ff7c-5a00-409e-9dcc-90f35b38d16e_0.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-001",
"seed": 281520112,
"timings": {
"inference": 3.193
Expand All @@ -193,6 +204,9 @@ Upon a successful request, the API will return the specific details of all batch
"api_id": "deefc5d7-7f22-43e9-929e-f2b6afee60b7",
"application_id": "001c2f84-2a4a-4c4d-ba3f-8a89f43b5be2",
"created_at": 1736304976.278,
"started_at": 1736304976.338,
"finished_at": 1736304985.938,
"elapsed": 9.6,
"credential_id": "b00bddd3-140f-4343-a9a2-affb312b60de",
"request": {
"action": "generate",
Expand All @@ -208,7 +222,7 @@ Upon a successful request, the API will return the specific details of all batch
"data": [
{
"prompt": "a white siamese cat",
"image_url": "https://sf-maas-uat-prod.oss-cn-shanghai.aliyuncs.com/outputs/57b5c7e5-3436-466d-86ed-583ede4a3d7c_0.png",
"image_url": "https://cdn.acedata.cloud/e724d7f13d.png?example=image-002",
"seed": 1437672535,
"timings": {
"inference": 3.175
Expand All @@ -222,11 +236,6 @@ Upon a successful request, the API will return the specific details of all batch
}
```

The returned result contains multiple fields, among which `items` includes the specific details of batch image tasks, and each image task's specific information is the same as the format of the single task return result mentioned above. The field information is as follows.

- `items`, all specific detail information of batch image tasks. It is an array, and each element of the array has the same format as the return result of querying a single task above.
- `count`, the number of image tasks in this batch query.

#### CURL

```bash
Expand Down Expand Up @@ -287,4 +296,4 @@ When calling the API, if an error occurs, the API will return the corresponding

## Conclusion

Through this document, you have learned how to use the FLux Tasks API to query all specific detail information of single or batch image tasks. We hope this document can help you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.
Through this document, you have learned how to use the FLux Tasks API to query the specific details of single or batch image tasks. We hope this document helps you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.
Loading