Flux Kontext Pro
FLUX.1 Kontext Pro transforms text prompts into high-quality, customized images with remarkable efficiency and precision.
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)
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
https://api.segmind.com/v1/flux-kontext-pro
Parameters
prompt
requiredstring
Describes the desired output or edit. To create lively imagery, try instructions like 'Turn this into a cyberpunk cityscape.'
aspect_ratio
optionalstring
Defines the image's width-to-height ratio. Choose '16:9' for widescreen or '1:1' for square images.
"match_input_image"
"match_input_image"
"1:1"
"16:9"
"9:16"
"4:3"
"3:4"
"3:2"
"2:3"
"4:5"
"5:4"
+4 moreinput_image
optionalstring (uri)
Image to edit or guide the generation. Use high-resolution images for the best quality results.
"https://segmind-resources.s3.amazonaws.com/input/e9150752-b054-445c-a988-c13c6038dfa9-kontext-pro-ip.webp"
output_format
optionalstring
Output format for the generated image.
"png"
"jpg"
"png"
safety_tolerance
optionalinteger
Safety tolerance, 0 is most strict and 6 is most permissive. 2 is currently the maximum allowed when input images are used.
2
seed
optionalinteger
Sets the random seed for generation consistency. Use specific numbers for repeatable results.
null
Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out