Flux 2 Flex Serverless API

FLUX.2 generates high-quality, photorealistic images with consistent style using multiple references for professional workflows.

~48.88s
~$0.172
 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

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

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