Flux 2 Flex Serverless API
Consistent-style photorealistic images using reference inputs.
POST /v2/flux-2-flex · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "flux-2-flex",
9 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.",
10 prompt_upsampling=True,
11 seed=42,
12 width=1024,
13 height=1024,
14 safety_tolerance=2,
15 guidance=5,
16 steps=50,
17 output_format="png",
18)
19print(result["status"]) # COMPLETED
20print(result.get("output")) # model output (e.g. media URL)
21print(result["metrics"]["inference_time"]) # server compute seconds
22
23# --- Or submit + poll manually (track request_id, control the cadence) ---
24from segmind import SegmindClient, InferenceFailed, InferenceTimeout
25
26client = SegmindClient() # reads SEGMIND_API_KEY
27payload = {
28 "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.",
29 "prompt_upsampling": True,
30 "seed": 42,
31 "width": 1024,
32 "height": 1024,
33 "safety_tolerance": 2,
34 "guidance": 5,
35 "steps": 50,
36 "output_format": "png",
37}
38job = client.submit_async("flux-2-flex", **payload)
39print(job.request_id) # available immediately
40try:
41 result = job.wait(timeout=600, interval=1.0)
42except InferenceTimeout as e:
43 print("still running:", e.request_id)
44except InferenceFailed as e:
45 print("failed:", e.detail) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3import segmind
4
5# Async (v2): submit to the queue and block until COMPLETED.
6# run() returns the final result dict (600s deadline, 1.0s poll by default).
7result = segmind.run(
8 "flux-2-flex",
9 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.",
10 prompt_upsampling=True,
11 seed=42,
12 width=1024,
13 height=1024,
14 safety_tolerance=2,
15 guidance=5,
16 steps=50,
17 output_format="png",
18)
19print(result["status"]) # COMPLETED
20print(result.get("output")) # model output (e.g. media URL)
21print(result["metrics"]["inference_time"]) # server compute seconds
22
23# --- Or submit + poll manually (track request_id, control the cadence) ---
24from segmind import SegmindClient, InferenceFailed, InferenceTimeout
25
26client = SegmindClient() # reads SEGMIND_API_KEY
27payload = {
28 "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.",
29 "prompt_upsampling": True,
30 "seed": 42,
31 "width": 1024,
32 "height": 1024,
33 "safety_tolerance": 2,
34 "guidance": 5,
35 "steps": 50,
36 "output_format": "png",
37}
38job = client.submit_async("flux-2-flex", **payload)
39print(job.request_id) # available immediately
40try:
41 result = job.wait(timeout=600, interval=1.0)
42except InferenceTimeout as e:
43 print("still running:", e.request_id)
44except InferenceFailed as e:
45 print("failed:", e.detail)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
Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/flux-2-flexSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
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