Flux Kontext Max API
Complete API reference for Flux Kontext Max with enhanced 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 Max (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-max',
prompt: 'A futuristic cityscape at night with neon lights',
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 Max (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-max',
prompt: 'Enhance this portrait with cinematic lighting',
width: 3,
height: 4,
image_url_list: ['https://example.com/portrait.jpg']
}
Multi-Image Composition Example
{
model_name: 'flux-kontext-max',
prompt: 'Merge these architectural photos into a unified panorama',
width: 21,
height: 9,
image_url_list: ['https://example.com/arch1.jpg', 'https://example.com/arch2.jpg', 'https://example.com/arch3.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.08,
"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-max"
}
Too Many Images
{
"code": 400,
"message": "Maximum 5 images allowed"
}
Best Practices
Text-to-Image Tips
- Detailed Prompts: Provide clear, detailed descriptions for best results
- Aspect Ratio: Choose appropriate aspect ratio for your use case
- Complex Scenes: Flux Kontext Max excels at complex, detailed scenes
- Efficient Polling: Check status every 2-3 seconds
Image-to-Image Tips
- Context-Aware: Leverage multi-image input for context-rich generation
- High-Quality Input: Use high-resolution source images for best results
- Clear Transformation Goals: Describe the desired outcome precisely
- Multi-Image Synergy: Combine up to 5 images for complex compositions
Example Use Cases
High-End Product Photography
{
model_name: 'flux-kontext-max',
prompt: 'Ultra-realistic product shot of diamond jewelry on black velvet',
width: 4,
height: 3
}
Architectural Visualization
{
model_name: 'flux-kontext-max',
prompt: 'Modern minimalist interior with natural lighting',
width: 16,
height: 9
}
Multi-Image Panorama
{
model_name: 'flux-kontext-max',
image_url_list: ['view1.jpg', 'view2.jpg', 'view3.jpg', 'view4.jpg'],
prompt: 'Seamless 360-degree panorama of mountain landscape',
width: 21,
height: 9
}
Advanced Style Transfer
{
model_name: 'flux-kontext-max',
image_url_list: ['photo.jpg'],
prompt: 'Transform into oil painting with Van Gogh style brushwork',
width: 1,
height: 1
}