Flux API
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 | true | Image Size: 1024x1024 1024x1792 1792x1024 Using different size will consume different quotas, for details |
mode | String | true | Use Mode: flux1-dev flux1-schnell : Generate the fastest flux model flux1-pro : The flux model that generates the best visual effects for images 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"
}
}
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
}
}