Flux Kontext Pro

FLUX.1 Kontext Pro transforms text prompts into high-quality, customized images with remarkable efficiency and precision.

~20.69s
$0.05 per generation
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/flux-kontext-pro"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "prompt": "make this a real photograph",
12    "input_image": "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp",
13    "aspect_ratio": "match_input_image",
14    "output_format": "png",
15    "safety_tolerance": 2
16}
17
18response = requests.post(url, headers=headers, json=data)
19
20if response.status_code == 200:
21    result = response.json()
22    print(json.dumps(result, indent=2))
23else:
24    print(f"Error: {response.status_code}")
25    print(response.text)

API Endpoint

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

Parameters

promptrequired
string

Describes the desired output or edit. To create lively imagery, try instructions like 'Turn this into a cyberpunk cityscape.'

aspect_ratiooptional
string

Defines the image's width-to-height ratio. Choose '16:9' for widescreen or '1:1' for square images.

Default: "match_input_image"
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)

Image to edit or guide the generation. Use high-resolution images for the best quality results.

Default: "https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp"
output_formatoptional
string

Output format for the generated image.

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

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

Default: 2
seedoptional
integer

Sets the random seed for generation consistency. Use specific numbers for repeatable results.

Default: null

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