Flux 2
Overview
Flux 2 is the next generation of the Flux text-to-image model family, offering improved performance, versatility, and quality. It supports both Text-to-Image and Image-to-Image generation.
Test API KEY: key_00000000000000000000000000000000Endpoints
1. Create Task
Request
POST https://api.pixwith.ai/api/task/createHeaders
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Api-Key | {API_KEY} | Yes |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | The input prompt (e.g., “a futuristic city”) |
| image_urls | array | Conditional | [“https://cdn.pixwith.ai/xxx.jpg ”]. Provide 1-4 images if doing image-to-image. |
| model_id | int | Yes | 0-28 (Flux 2 Dev) or 0-29 (Flux 2 Pro) |
| options | object | Yes | Configuration options for the task |
| options.prompt_optimization | boolean | Yes | If true, all prompt words will be automatically translated into English. |
| options.aspect_ratio | string | Yes | Aspect ratio of the output. Valid values: '0' (Match Input), '1:1', '16:9', '3:2', '2:3', '4:5', '5:4', '9:16', '3:4', '4:3'. Default: '1:1' |
| options.resolution | string | Optional | Resolution of the output. Only available for model_id 0-29 (Flux 2 Pro). Valid values: '720p', '1080p', '2K'. Default: '720p'. |
Example Request - Text-to-Image (Flux 2 Dev)
{
"prompt": "a futuristic city",
"model_id": "0-28",
"options": {
"prompt_optimization": true,
"aspect_ratio": "16:9"
}
}Example Request - Text-to-Image (Flux 2 Pro)
{
"prompt": "a futuristic city",
"model_id": "0-29",
"options": {
"prompt_optimization": true,
"aspect_ratio": "16:9",
"resolution": "1080p"
}
}Example Request - Image-to-Image
{
"prompt": "make it anime style",
"image_urls": ["https://cdn.pixwith.ai/example.jpg"],
"model_id": "0-29",
"options": {
"prompt_optimization": true,
"aspect_ratio": "16:9",
"resolution": "1080p"
}
}Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | int | 1=success, 0=error |
| message | string | Success and failure messages |
| data | object | |
| data.task_id | string | |
| data.estimated_time | int | Estimated time in seconds |
Response
{
"code": 1,
"message": "success",
"data": {
"task_id": "d425ab4dc256f0ebaa84862b9cea8a3d",
"estimated_time": 60
}
}Last updated on