Flux Kontext API
The Flux Kontext API provides advanced AI image generation with superior context understanding. Generate high-quality images that better understand spatial relationships, object placement, and scene composition from your text descriptions.
Quick Start
Generate your first context-aware AI image in 30 seconds
Get Your API Key
Sign in to your account to get your API key and see it automatically filled in all code examples.
Don't have an account? Sign up for free
import requests
# Generate your first context-aware AI image
response = requests.post(
"https://netwrck.com/api/flux-kontext",
json={
"api_key": "YOUR_API_KEY",
"prompt": "A red apple on a wooden table next to a blue vase, natural lighting",
"size": "1024x1024"
}
)
result = response.json()
print(f"Image generated: {result['image_url']}")
print(f"Cost: {result['credits_charged']} credits")
// Generate your first context-aware AI image
fetch('https://netwrck.com/api/flux-kontext', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
api_key: 'YOUR_API_KEY',
prompt: 'A red apple on a wooden table next to a blue vase, natural lighting',
size: '1024x1024'
})
})
.then(res => res.json())
.then(result => {
console.log('Image generated:', result.image_url);
console.log('Cost:', result.credits_charged, 'credits');
})
.catch(error => console.error('Error:', error));
# Generate your first context-aware AI image
curl -X POST https://netwrck.com/api/flux-kontext \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_API_KEY",
"prompt": "A red apple on a wooden table next to a blue vase, natural lighting",
"size": "1024x1024"
}'
Authentication
All API requests require your API key. Sign in to get your API key and see it automatically filled in all code examples.
{
"api_key": "YOUR_API_KEY"
}
Pricing & Credits
Cost Per Image
$0.04 USD
4 credits per successful generation
Billing Policy
Success: Charged 4 credits
Failed: No charge
Only pay for successful generations
API Reference
POST /api/flux-kontext
Generate context-aware AI images with superior spatial understanding
📝 Request Format
Send a POST request with a JSON body containing these parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Required | Your API key for authentication. |
| prompt | string | Required | Text description of the image. Flux Kontext excels at understanding spatial relationships and object placement. Max 1000 characters. |
| image_url | string | Optional | Reference image URL to guide generation. Supports JPG, PNG, WEBP formats. Max 10MB. |
| size | string | Optional |
Image size in widthxheight format. Default: "1024x1024".
Supported sizes:
|
Response Examples
Success Response (200 OK)
When your image is successfully generated, you'll receive:
{
"image_url": "https://netwrckstatic.netwrck.com/static/uploads/ai/flux-kontext-image.webp",
"prompt_used": "A red apple on a wooden table next to a blue vase, natural lighting",
"size_used": "1024x1024",
"credits_charged": 4
}
Error Responses
If something goes wrong, you'll receive one of these error responses:
401 Unauthorized
{
"error": "Invalid API key",
"status": 401
}
Check your API key is correct
402 Payment Required
{
"error": "Insufficient credits",
"status": 402
}
Add more credits to your account
400 Bad Request
{
"error": "Prompt is required",
"status": 400
}
Check your request parameters
500 Server Error
{
"error": "Internal server error",
"status": 500
}
Try again in a moment
Pro Tips for Better Results
Context-Aware Prompting
- Specify spatial relationships: "next to", "behind", "in front of"
- Use directional terms: "on the left", "in the center", "at the bottom"
- Describe object interactions: "resting on", "leaning against"
- Include environment details: "on a wooden table", "against a brick wall"
Reference Images
- Use reference images for composition guidance
- Images help define layout and positioning
- Combine with detailed prompts for best results
- JPG, PNG, WEBP formats supported (max 10MB)
Example Context-Rich Prompts
"A vintage camera positioned on the left side of a mahogany desk, with an open notebook on the right side and a coffee mug in the center background"
"Three potted plants arranged in a row on a white windowsill, the tallest one on the left casting shadows on the middle plant, morning sunlight streaming through"
"A black cat sitting upright on a red velvet cushion placed on the corner of a Victorian armchair, with a bookshelf visible in the soft-focus background"
Netwrck