Skip to content

This service implements the integration of Flux AI and can be used to generate images and other content.

Notifications You must be signed in to change notification settings

AceDataCloud/FluxAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Flux Image Generation API

This service implements the integration of Flux AI and can be used to generate images and other content.

API home page: Ace Data Cloud - Flux Image Generation

Get Started

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

Next, we will introduce the integration instructions for the Flux Images Generation API.

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 provided, allowing you to use the API for free.

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:

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

  • accept: the format of the response result you want to receive, filled in as application/json, which means JSON format.
  • authorization: the key to call the API, which can be selected directly after application.

Additionally, we have set the Request Body, including:

  • action: the action for 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.
  • callback_url: the URL to receive the callback result.

After selection, you can find that the corresponding code is also generated on the right side, as shown in the image below:

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

{
  "success": true,
  "task_id": "226eb763-9eab-4d06-ad57-d59753a03307",
  "trace_id": "089f8b46-0167-4f25-88ee-3c3f88d80e84",
  "data": [
    {
      "prompt": "a white siamese cat",
      "image_url": "https://fal.media/files/lion/NVhtlwwGYQD6HrGaEfrzu_341484fad6d84b21b73f4f8824a3f98a.png",
      "timings": 1752743801
    },
    {
      "prompt": "a white siamese cat",
      "image_url": "https://fal.media/files/monkey/8UEQpFbQCYVOK1wKP3aV0_9bbc26fad64049b18d0244b99ef66ad1.png",
      "timings": 1752743801
    }
  ]
}

The returned result contains multiple fields, described as follows:

  • 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.
    • prompt: the prompt.

We can see that we have obtained satisfactory image information, and we only need to retrieve the generated Flux images based on the image link address in the 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:

curl -X POST 'https://api.acedata.cloud/flux/images' \
-H 'authorization: Bearer {token}' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
  "action": "generate",
  "prompt": "a white siamese cat",
  "model": "flux-kontext-pro",
  "count": 2
}'

Editing Image Tasks

If you want to edit a specific image, the parameter image_url must first be passed with the link to the image that needs to be edited. At this time, action only supports edits, and you can specify the following content:

  • model: the model used for this image editing task, which currently supports flux-kontext-max and flux-kontext-pro.
  • image_url: the uploaded image that needs to be edited.

An example of the input is as follows:

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

The corresponding code:

import requests

url = "https://api.acedata.cloud/flux/images"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "action": "edits",
    "prompt": "a white siamese cat",
    "model": "flux-kontext-pro",
    "image_url": "https://cdn.acedata.cloud/ytj2qy.png"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

Clicking run, you can find that you will immediately get a result, as follows:

{
  "success": true,
  "task_id": "2a7979ff-1f77-4380-92c6-a2dc37c3b4c8",
  "trace_id": "732b65c0-48d9-49f7-b568-64e5acffe4c0",
  "data": [
    {
      "prompt": "a white siamese cat",
      "image_url": "https://fal.media/files/monkey/aEUXJZ6Faj9YXUCQVs01Q_af0cea56c558441c9ba8df67b200812d.png",
      "timings": 1752744073
    }
  ]
}

As you can see, the generated effect is the result of editing the original image, similar to the previous text.

More

For more info, please check below APIs and integration documents.

API Path Integration Guidance
Flux Images Generation API /flux/images Flux Images Generation API Integration Guide
Flux Tasks API /flux/tasks Flux Tasks API Integration Guide

Base URL: https://api.acedata.cloud

Support

If you meet any issue, check our from support info.

About

This service implements the integration of Flux AI and can be used to generate images and other content.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published