Flux 2 Pro Serverless API

FLUX.2 generates photorealistic images while ensuring consistency across multiple assets using reference images.

~26.19s
~$0.073
 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

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

Parameters

image_urlsrequired
string[]

Provide URLs for reference images. Ensure URLs are valid and image quality is high.

promptrequired
string

Text prompt guides image creation. Use descriptive phrases for detailed images.

Default: "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!”"
heightoptional
integer

Set image height. Adjust based on aspect ratio needs or desired output dimension.

Default: 1024
output_formatoptional
string

Choose image format. Use 'jpeg' for quality, 'png' for transparency.

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

Adjust safety levels for moderation. Higher values for stricter checking.

Default: 3Range: 0 - 6
seedoptional
integer

Seed allows image reproducibility. Use specific numbers for consistency, random for variety.

Default: 42
widthoptional
integer

Set image width. Use larger sizes for detail, smaller for quick generation.

Default: 1024

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