Flux 2 Flex Serverless API
FLUX.2 generates high-quality, photorealistic images with consistent style using multiple references for professional workflows.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-flex"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Soft, weightless 3D letters shaped from glowing, vapor-like aurora mist spelling “Flex”, drifting gently above a crystalline tundra at polar twilight. The colors shift between icy teal, luminescent violet, and pale arctic rose, with diaphanous wisps curling from the edges like illuminated fog. The scene is set inside a vast glacier cavern filled with refractive ice columns and shimmering frost patterns that catch and scatter the ambient light. Shot on Cinestill 800T with a Hasselblad 503CW—cool cinematic tones, gentle halation around the luminous mist-letters, and crisp detail on the faceted ice. A holographic expedition beacon stands in the background, its soft projection displaying “Try FLUX.2 Flex on Segmind!” against the glowing walls, with drifting snow crystals suspended in the still, icy air.",
12 "prompt_upsampling": true,
13 "seed": 42,
14 "width": 1024,
15 "height": 1024,
16 "safety_tolerance": 2,
17 "guidance": 5,
18 "steps": 50,
19 "output_format": "png"
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25 result = response.json()
26 print(json.dumps(result, indent=2))
27else:
28 print(f"Error: {response.status_code}")
29 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-flex"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Soft, weightless 3D letters shaped from glowing, vapor-like aurora mist spelling “Flex”, drifting gently above a crystalline tundra at polar twilight. The colors shift between icy teal, luminescent violet, and pale arctic rose, with diaphanous wisps curling from the edges like illuminated fog. The scene is set inside a vast glacier cavern filled with refractive ice columns and shimmering frost patterns that catch and scatter the ambient light. Shot on Cinestill 800T with a Hasselblad 503CW—cool cinematic tones, gentle halation around the luminous mist-letters, and crisp detail on the faceted ice. A holographic expedition beacon stands in the background, its soft projection displaying “Try FLUX.2 Flex on Segmind!” against the glowing walls, with drifting snow crystals suspended in the still, icy air.",
12 "prompt_upsampling": true,
13 "seed": 42,
14 "width": 1024,
15 "height": 1024,
16 "safety_tolerance": 2,
17 "guidance": 5,
18 "steps": 50,
19 "output_format": "png"
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25 result = response.json()
26 print(json.dumps(result, indent=2))
27else:
28 print(f"Error: {response.status_code}")
29 print(response.text)API Endpoint
https://api.segmind.com/v1/flux-2-flexParameters
image_urlsrequiredstring[]URLs of base images for creative modifications. Example: 'https://example.com/sample-image.jpg'.
promptrequiredstringThe main idea or theme for the image generation. Try 'sunset over a futuristic city' for dramatic effects.
"Soft, weightless 3D letters shaped from glowing, vapor-like aurora mist spelling “Flex”, drifting gently above a crystalline tundra at polar twilight. The colors shift between icy teal, luminescent violet, and pale arctic rose, with diaphanous wisps curling from the edges like illuminated fog. The scene is set inside a vast glacier cavern filled with refractive ice columns and shimmering frost patterns that catch and scatter the ambient light. Shot on Cinestill 800T with a Hasselblad 503CW—cool cinematic tones, gentle halation around the luminous mist-letters, and crisp detail on the faceted ice. A holographic expedition beacon stands in the background, its soft projection displaying “Try FLUX.2 Flex on Segmind!” against the glowing walls, with drifting snow crystals suspended in the still, icy air."guidanceoptionalstringGuides image creation towards the prompt; use 7 for vivid adherence.
5heightoptionalintegerControls the image height; minimum is 64. Choose 1024 for detailed canvases.
1024output_formatoptionalstringDetermines the file format: 'jpeg' for compression, 'png' for quality.
"png""jpeg""png"prompt_upsamplingoptionalbooleanEnhances prompt detail for higher clarity. Use true for sharper images in artistic projects.
truesafety_toleranceoptionalintegerAdjusts moderation level from 0 (strict) to 6 (lenient). Use 3 for balanced filtering.
2Range: 0 - 6seedoptionalintegerSeed ensures reproducibility of results. Use different numbers for varied artwork versions.
42stepsoptionalintegerDefines the detail level; 30 for quick renders, 50 for intricate textures.
50Range: 1 - 50widthoptionalintegerControls the image width; minimum is 64. Opt for 1024 for larger, detailed images.
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