Flux-2 Klein-9b Serverless API
FLUX.2 [klein] enables ultra-fast, photorealistic image generation on consumer GPUs, transforming creative workflows.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-klein-9b"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "make the woman in image 1 wear the open cardigan from image 2.",
12 "image_urls": [
13 "https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png",
14 "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"
15 ],
16 "negative_prompt": "low quality, blurry, less details",
17 "seed": 3425234,
18 "cfg": 5,
19 "sampler": "euler",
20 "steps": 20,
21 "aspect_ratio": "1:1",
22 "go_fast": true,
23 "image_format": "png",
24 "quality": 90
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-2-klein-9b"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "make the woman in image 1 wear the open cardigan from image 2.",
12 "image_urls": [
13 "https://segmind-resources.s3.amazonaws.com/output/42b545b8-3175-45d8-8988-7df5d6d33a18-d59764eb-c62c-4453-8361-16165743d62c.png",
14 "https://segmind-resources.s3.amazonaws.com/output/91a90af8-002a-4980-9c5e-27c8860ae659-cb60b30f527b4e9b87391c2d0d4167a5.jpeg"
15 ],
16 "negative_prompt": "low quality, blurry, less details",
17 "seed": 3425234,
18 "cfg": 5,
19 "sampler": "euler",
20 "steps": 20,
21 "aspect_ratio": "1:1",
22 "go_fast": true,
23 "image_format": "png",
24 "quality": 90
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text)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[]Add a reference image or leave blank for original ideas(text to image mode.
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
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