Flux-2 Klein-9b Serverless API
Ultra-fast photorealistic image generation on consumer GPUs.
POST /v2/flux-2-klein-9b · 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-klein-9b",
9 prompt="make the woman in image 1 wear the open cardigan from image 2.",
10 image_urls=["https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png", "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"],
11 negative_prompt="low quality, blurry, less details",
12 seed=3425234,
13 cfg=5,
14 sampler="euler",
15 steps=20,
16 aspect_ratio="1:1",
17 go_fast=True,
18 image_format="png",
19 quality=90,
20)
21print(result["status"]) # COMPLETED
22print(result.get("output")) # model output (e.g. media URL)
23print(result["metrics"]["inference_time"]) # server compute seconds
24
25# --- Or submit + poll manually (track request_id, control the cadence) ---
26from segmind import SegmindClient, InferenceFailed, InferenceTimeout
27
28client = SegmindClient() # reads SEGMIND_API_KEY
29payload = {
30 "prompt": "make the woman in image 1 wear the open cardigan from image 2.",
31 "image_urls": ["https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png", "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"],
32 "negative_prompt": "low quality, blurry, less details",
33 "seed": 3425234,
34 "cfg": 5,
35 "sampler": "euler",
36 "steps": 20,
37 "aspect_ratio": "1:1",
38 "go_fast": True,
39 "image_format": "png",
40 "quality": 90,
41}
42job = client.submit_async("flux-2-klein-9b", **payload)
43print(job.request_id) # available immediately
44try:
45 result = job.wait(timeout=600, interval=1.0)
46except InferenceTimeout as e:
47 print("still running:", e.request_id)
48except InferenceFailed as e:
49 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-klein-9b",
9 prompt="make the woman in image 1 wear the open cardigan from image 2.",
10 image_urls=["https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png", "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"],
11 negative_prompt="low quality, blurry, less details",
12 seed=3425234,
13 cfg=5,
14 sampler="euler",
15 steps=20,
16 aspect_ratio="1:1",
17 go_fast=True,
18 image_format="png",
19 quality=90,
20)
21print(result["status"]) # COMPLETED
22print(result.get("output")) # model output (e.g. media URL)
23print(result["metrics"]["inference_time"]) # server compute seconds
24
25# --- Or submit + poll manually (track request_id, control the cadence) ---
26from segmind import SegmindClient, InferenceFailed, InferenceTimeout
27
28client = SegmindClient() # reads SEGMIND_API_KEY
29payload = {
30 "prompt": "make the woman in image 1 wear the open cardigan from image 2.",
31 "image_urls": ["https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png", "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"],
32 "negative_prompt": "low quality, blurry, less details",
33 "seed": 3425234,
34 "cfg": 5,
35 "sampler": "euler",
36 "steps": 20,
37 "aspect_ratio": "1:1",
38 "go_fast": True,
39 "image_format": "png",
40 "quality": 90,
41}
42job = client.submit_async("flux-2-klein-9b", **payload)
43print(job.request_id) # available immediately
44try:
45 result = job.wait(timeout=600, interval=1.0)
46except InferenceTimeout as e:
47 print("still running:", e.request_id)
48except InferenceFailed as e:
49 print("failed:", e.detail)API Endpoint
https://api.segmind.com/v1/flux-2-klein-9bParameters
promptrequiredstringPrompt describing the image to generate
aspect_ratiooptionalstringAspect ratio of the output image
"1:1""match_input_image""1:1""2:3""3:2""3:4""4:3""4:5""5:4""9:16""16:9"+1 morecfgoptionalnumberClassifier-free guidance scale
5Range: 1 - 20go_fastoptionalbooleanEnable fast generation mode
trueimage_formatoptionalstringOutput image format
"png""png""jpeg""webp"image_urlsoptionalstring[]Reference image URL. Leave blank for text-to-image generation.
negative_promptoptionalstringNegative prompt to avoid certain elements
"low quality, blurry, less details"qualityoptionalintegerOutput image quality
90Range: 10 - 100sampleroptionalstringSampling method
"euler""euler""res_2s"seedoptionalintegerRandom seed for reproducibility
3425234stepsoptionalintegerNumber of inference steps
20Range: 1 - 100Response 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-klein-9bSubmit — 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