Flux API IN TTAPI Format
Flux, Black Forest's groundbreaking text-to-image model transforming words into stunning visuals—now available on TTAPI
Generate Image
POST https://api.ttapi.io/flux/generate
Generate images from text use Flux. Task results is async
Headers
| Name | Type | Required | Description | 
|---|---|---|---|
| TT-API-KEY | String | true | Your API Key in TT API used for request authorization | 
Request Body
| Name | Type | Required | Description | 
|---|---|---|---|
| prompt | String | true | Prompt use to generate image | 
| size | String | false | Image Size: 1024x1024 1024x1792 1792x1024  | 
| aspect_ratio | String | false | Aspect Ratio: 21:9, 16:9, 4:3, 3:2, 1:1, 2:3, 3:4, 9:16, 9:21(default 1:1)  | 
| mode | String | true | Use Mode: flux1-dev flux1-schnell flux1-pro flux-kontext-pro flux-kontext-max Using different models will consume different quotas, for details  | 
| hookUrl | String | false | Send a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response | 
Example Request
import requests
endpoint = "https://api.ttapi.io/flux/generate"
headers = {
    "TT-API-KEY": your_key
}
data = {
    "prompt": "a cat",
    "size": "1024x1792",
    "model": "flux1-dev"
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())Example Response
{
    "status": "SUCCESS",
    "message": "",
    "data": {
        "jobId": "ed1a1b01-7d64-4c8a-acaa-71185d23a2f3"
    }
}Edit Image
POST https://api.ttapi.io/flux/edits
Generate new images based on text prompts and uploaded images. Task results is async
Headers
| Name | Type | Required | Description | 
|---|---|---|---|
| TT-API-KEY | String | true | Your API Key in TT API used for request authorization | 
Request Body
| Name | Type | Required | Description | 
|---|---|---|---|
| image | File | true | Images used for modification, supports multiple images | 
| prompt | String | true | Prompt use to generate image | 
| aspect_ratio | String | false | Aspect Ratio: 21:9, 16:9, 4:3, 3:2, 1:1, 2:3, 3:4, 9:16, 9:21(default 1:1)  | 
| mode | String | true | Use Mode: flux1-dev flux1-schnell flux1-pro flux-kontext-pro flux-kontext-max Using different models will consume different quotas, for details  | 
| hookUrl | String | false | Send a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response | 
Example Request
import requests
 
url = "https://api.ttapi.io/flux/edits"
 
data={
    "prompt": "a cute cat",
    "mode": "flux1-dev"
}
files=[
('image',('',open('','rb'),'application/octet-stream'))
]
headers = {
    'TT-API-KEY': 'Your Key'
}
 
response = requests.post(endpoint, headers=headers, json=data, files=files)
 
print(response.status_code)
print(response.json())Example Response
{
    "status": "SUCCESS",
    "message": "",
    "data": {
        "jobId": "ed1a1b01-7d64-4c8a-acaa-71185d23a2f3"
    }
}Fetch Flux Result
POST/GET https://api.ttapi.io/flux/fetch
Get the flux generate image task result, the returned json data is same with the return in hookUrl
Headers
| Name | Type | Description | 
|---|---|---|
| TT-API-KEY* | String | Your API Key in TT API used for request authorization | 
Request Body / Query param
| Name | Type | Required | Description | 
|---|---|---|---|
| jobId | String | true | ed1a1b01-7d64-4c8a-acaa-71185d23a2f3 | 
Example Request
import requests
endpoint = "https://api.ttapi.io/flux/fetch"
headers = {
    "TT-API-KEY": your_key
}
data = {
    "jobId": "f11a93ac-128d-4b09-9b43-2a7e60488f9c",
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())Async callback & fetch json
{
    "status": "SUCCESS",
    "message": "success",
    "jobId": "f11a93ac-128d-4b09-9b43-2a7e60488f9c",
    "data": {
        "mode": "flux1-pro",
        "jobId": "f11a93ac-128d-4b09-9b43-2a7e60488f9c",
        "prompt": "Two children sitting in a waiting room with their parents, having just seen the doctor, looking relieved.",
        "quota": "3",
        "size": "1792x1024",
        "imageUrl": "https://cdnb.ttapi.io/2024-09-13/172619678031lqb1bjvkeagt2q4lqvpncvl4wk7h42.png",
        "hookUrl": null
    }
}