Flux 2 Flex Serverless API

Consistent-style photorealistic images using reference inputs.

~41.81s
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)

API Endpoint

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

Parameters

image_urlsrequired
string[]

URLs of base images for creative modifications. Example: 'https://example.com/sample-image.jpg'.

promptrequired
string

The main idea or theme for the image generation. Try 'sunset over a futuristic city' for dramatic effects.

Default: "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."
guidanceoptional
string

Guides image creation towards the prompt; use 7 for vivid adherence.

Default: 5
heightoptional
integer

Controls the image height; minimum is 64. Choose 1024 for detailed canvases.

Default: 1024
output_formatoptional
string

Determines the file format: 'jpeg' for compression, 'png' for quality.

Default: "png"
Allowed values :
"jpeg""png"
prompt_upsamplingoptional
boolean

Enhances prompt detail for higher clarity. Use true for sharper images in artistic projects.

Default: true
safety_toleranceoptional
integer

Adjusts moderation level from 0 (strict) to 6 (lenient). Use 3 for balanced filtering.

Default: 2Range: 0 - 6
seedoptional
integer

Seed ensures reproducibility of results. Use different numbers for varied artwork versions.

Default: 42
stepsoptional
integer

Defines the detail level; 30 for quick renders, 50 for intricate textures.

Default: 50Range: 1 - 50
widthoptional
integer

Controls the image width; minimum is 64. Opt for 1024 for larger, detailed images.

Default: 1024

Response 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. 1
    POST /v2/flux-2-flex

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • 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.

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