Flux Kontext Pro API
Complete API reference for Flux Kontext Pro with multi-image context understanding.
Model Overview
Quick Comparison
Supported Aspect Ratios
Both modes support 9 aspect ratios:
1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 21:9, 9:21
Cost
Flux Kontext Pro (Text-to-Image)
Endpoint
POST /api/v1/image/task
Authentication
Authorization: Bearer YOUR_API_KEY
Request Parameters
Required
Note: The width:height ratio must be one of: "1:1", "16:9", "9:16", "3:2", "2:3", "4:3", "3:4", "21:9", "9:21"
Example Request
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'flux-kontext-pro',
prompt: 'A serene mountain landscape at sunset',
width: 16,
height: 9
})
});
const { data } = await response.json();
const taskId = data.task_id;
const pollResponse = await fetch(
`https://api.flaq.ai/api/v1/image/${taskId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const result = await pollResponse.json();
console.log(result.data.task_result.images[0].url);
Flux Kontext Pro (Image-to-Image)
Endpoint
POST /api/v1/image/task
Request Parameters
Required
Note: The width:height ratio must be one of: "1:1", "16:9", "9:16", "3:2", "2:3", "4:3", "3:4", "21:9", "9:21"
Single Image Edit Example
{
model_name: 'flux-kontext-pro',
prompt: 'Transform this photo into a watercolor painting',
width: 16,
height: 9,
image_url_list: ['https://example.com/image.jpg']
}
Multi-Image Composition Example
{
model_name: 'flux-kontext-pro',
prompt: 'Combine these images into a cohesive landscape scene',
width: 16,
height: 9,
image_url_list: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg', 'https://example.com/image3.jpg']
}
Initial Response
Both modes return a task_id for polling:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "submitted",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}"
},
"message": "success"
}
Polling Response
Poll /api/v1/image/{taskId} to check status:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_result": {
"credit": 0.04,
"images": [
{
"url": "https://example.com/generated-image.jpeg"
}
]
}
},
"message": "success"
}
Status Values
submitted: Task accepted
processing: Generation in progress
succeed: Generation completed successfully
failed: Generation failed
Error Handling
Common Errors
Invalid Aspect Ratio
{
"code": 400,
"message": "Ratio must be one of: 1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 21:9, 9:21"
}
Missing Image URL (Image-to-Image Mode)
{
"code": 400,
"message": "image_url_list is required for flux-kontext-pro"
}
Too Many Images
{
"code": 400,
"message": "Maximum 5 images allowed"
}
Best Practices
Text-to-Image Tips
- Be Specific: Include subject, style, lighting, composition details
- Aspect Ratio Selection: Choose ratio based on your use case (16:9 for web, 9:16 for mobile)
- Prompt Quality: More detailed prompts generally produce better results
- Efficient Polling: Check status every 2-3 seconds
Image-to-Image Tips
- Clear Instructions: Be specific about the desired transformation
- Multi-Image Context: Can combine up to 5 images for context-aware generation
- Prompt Guidance: Describe the desired outcome, not just the changes
- Image Quality: Higher quality input images produce better results
Example Use Cases
Product Photography
{
model_name: 'flux-kontext-pro',
prompt: 'Professional product shot of luxury watch on marble surface',
width: 4,
height: 3
}
Multi-Image Collage
{
model_name: 'flux-kontext-pro',
image_url_list: ['photo1.jpg', 'photo2.jpg', 'photo3.jpg'],
prompt: 'Create a seamless collage with these vacation photos',
width: 16,
height: 9
}
Style Transfer
{
model_name: 'flux-kontext-pro',
image_url_list: ['photo.jpg'],
prompt: 'Transform into impressionist painting style',
width: 1,
height: 1
}