Flux Kontext Max Serverless API

FLUX.1 Kontext [max] transforms textual descriptions into stunning, high-fidelity images with seamless typography integration.

~24.34s
$0.1 per generation
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/flux-kontext-max"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "seed": 30699,
12    "prompt": "Make her take a selfie in the streets of Freiburg, it's a lovely day out",
13    "input_image": "https://segmind-resources.s3.amazonaws.com/input/a1adf47e-bfba-45c4-a11f-ae2b732102ad-kontext-max-ip.webp",
14    "aspect_ratio": "16:9",
15    "output_format": "png",
16    "safety_tolerance": 6
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22    result = response.json()
23    print(json.dumps(result, indent=2))
24else:
25    print(f"Error: {response.status_code}")
26    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/flux-kontext-max

Parameters

promptrequired
string

Describe what you want to generate. Suggest vibrant scenes for maximum creativity.

aspect_ratiooptional
string

Select the image aspect ratio. Common choices are 16:9 for landscapes or 1:1 for portraits.

Default: "16:9"
Allowed values (14 total):
"match_input_image""1:1""16:9""9:16""4:3""3:4""3:2""2:3""4:5""5:4"+4 more
input_imageoptional
string (uri)

Provide a reference image URL. Use high quality images for best guidance.

Default: "https://segmind-resources.s3.amazonaws.com/input/a1adf47e-bfba-45c4-a11f-ae2b732102ad-kontext-max-ip.webp"
output_formatoptional
string

Output format for the generated image.

Default: "png"
Allowed values :
"jpg""png"
safety_toleranceoptional
integer

Safety tolerance, 1 is most strict and 6 is most permissive. 2 is currently the maximum allowed when input images are used.

Default: 2
seedoptional
integer

Set a random seed for consistent results. Useful for generating identical outputs in repeated tasks.

Default: 123

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out