Flux Dev Finetuned Serverless API
Flux is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions
1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-dev-finetuned"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "TOK TOK",
12 "steps": 25,
13 "seed": 6652105,
14 "scheduler": "simple",
15 "sampler_name": "euler",
16 "aspect_ratio": "1:1",
17 "lora_strength": 1,
18 "hardware": "cost"
19}
20
21response = requests.post(url, headers=headers, json=data)
22
23if response.status_code == 200:
24 result = response.json()
25 print(json.dumps(result, indent=2))
26else:
27 print(f"Error: {response.status_code}")
28 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-dev-finetuned"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "TOK TOK",
12 "steps": 25,
13 "seed": 6652105,
14 "scheduler": "simple",
15 "sampler_name": "euler",
16 "aspect_ratio": "1:1",
17 "lora_strength": 1,
18 "hardware": "cost"
19}
20
21response = requests.post(url, headers=headers, json=data)
22
23if response.status_code == 200:
24 result = response.json()
25 print(json.dumps(result, indent=2))
26else:
27 print(f"Error: {response.status_code}")
28 print(response.text)API Endpoint
https://api.segmind.com/v1/flux-dev-finetunedParameters
aspect_ratiorequiredstringAspect ratio for the generated image
"1:1""1:1""2:3""3:4""5:8""9:16""9:19""9:21""3:2""4:3""8:5"+3 morefinetune_idrequiredstringID of the fine-tuned model you want to use.
"my-finetune-id"lora_strengthrequirednumberStrength of the LoRA (Low-Rank Adaptation) for fine-tuning
1Range: -10 - 10promptrequiredstringText prompt for generating the image
"TOK TOK"sampler_namerequiredstringSampler type for image generation
"euler""euler""euler_pp""euler_ancestral""euler_ancestral_pp""heun""heunpp2""dpm_2""dpm_2_ancestral""lms""dpm_fast"+16 moreschedulerrequiredstringScheduler type for image generation
"simple""normal""karras""exponential""sgm_uniform""simple""ddim_uniform""beta"seedrequiredintegerSeed for random number generation
6652105stepsrequiredintegerNumber of steps for generating the image
25Range: 1 - 100hardwareoptionalstringThe hardware to use. Does not affect quality, only latency and cost
"cost""fast""cost"Response Type
Returns: Text/JSON
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