Flux 2 Pro Serverless API
FLUX.2 generates photorealistic images while ensuring consistency across multiple assets using reference images.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-pro"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”",
12 "seed": 42,
13 "width": 1024,
14 "height": 1024,
15 "safety_tolerance": 3,
16 "output_format": "png"
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) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-pro"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”",
12 "seed": 42,
13 "width": 1024,
14 "height": 1024,
15 "safety_tolerance": 3,
16 "output_format": "png"
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
https://api.segmind.com/v1/flux-2-proParameters
image_urlsrequiredstring[]Provide URLs for reference images. Ensure URLs are valid and image quality is high.
promptrequiredstringText prompt guides image creation. Use descriptive phrases for detailed images.
"Iridescent neon 3D letters in sapphire blue, ultraviolet purple, and laser-green glowing against a futuristic dusk skyline. Set on a rooftop helipad with brushed-steel textures, holographic signage, and soft under-lighting. Shot on Fuji Velvia with a Mamiya RZ67 — crisp contrast, cool-magenta twilight tones, and a cinematic cyber-noir atmosphere. Subtle chromatic aberration, gentle bokeh from distant city lights, and a faint blue lens flare sweeping across the frame. Sleek air-drones drift in the background above a neon-lined metropolis, while the glossy letters in the foreground spell out “Try FLUX.2 Pro on Segmind!”"heightoptionalintegerSet image height. Adjust based on aspect ratio needs or desired output dimension.
1024output_formatoptionalstringChoose image format. Use 'jpeg' for quality, 'png' for transparency.
"png""jpeg""png"safety_toleranceoptionalintegerAdjust safety levels for moderation. Higher values for stricter checking.
3Range: 0 - 6seedoptionalintegerSeed allows image reproducibility. Use specific numbers for consistency, random for variety.
42widthoptionalintegerSet image width. Use larger sizes for detail, smaller for quick generation.
1024Response 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