Flux-2 Klein-9b Serverless API

Ultra-fast photorealistic image generation on consumer GPUs.

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

API Endpoint

POSThttps://api.segmind.com/v1/flux-2-klein-9b

Parameters

promptrequired
string

Prompt describing the image to generate

aspect_ratiooptional
string

Aspect ratio of the output image

Default: "1:1"
Allowed values (11 total):
"match_input_image""1:1""2:3""3:2""3:4""4:3""4:5""5:4""9:16""16:9"+1 more
cfgoptional
number

Classifier-free guidance scale

Default: 5Range: 1 - 20
go_fastoptional
boolean

Enable fast generation mode

Default: true
image_formatoptional
string

Output image format

Default: "png"
Allowed values :
"png""jpeg""webp"
image_urlsoptional
string[]

Reference image URL. Leave blank for text-to-image generation.

negative_promptoptional
string

Negative prompt to avoid certain elements

Default: "low quality, blurry, less details"
qualityoptional
integer

Output image quality

Default: 90Range: 10 - 100
sampleroptional
string

Sampling method

Default: "euler"
Allowed values :
"euler""res_2s"
seedoptional
integer

Random seed for reproducibility

Default: 3425234
stepsoptional
integer

Number of inference steps

Default: 20Range: 1 - 100

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-klein-9b

    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