Stable Diffusion XL 1.0
The SDXL model is the official upgrade to the v1.5 model. The model is released as open-source software
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/sdxl1.0-txt2img"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "prompt": "cinematic film still, 4k, realistic, ((cinematic photo:1.3)) of panda wearing a blue spacesuit, sitting in a bar, Fujifilm XT3, long shot, ((low light:1.4)), ((looking straight at the camera:1.3)), upper body shot, somber, shallow depth of field, vignette, highly detailed, high budget Hollywood movie, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
12    "negative_prompt": "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft",
13    "style": "base",
14    "samples": 1,
15    "scheduler": "UniPC",
16    "num_inference_steps": 25,
17    "guidance_scale": 8,
18    "strength": 0.2,
19    "high_noise_fraction": 0.8,
20    "seed": 468685,
21    "img_width": 896,
22    "img_height": 1152,
23    "refiner": true,
24    "base64": false
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/sdxl1.0-txt2img"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "prompt": "cinematic film still, 4k, realistic, ((cinematic photo:1.3)) of panda wearing a blue spacesuit, sitting in a bar, Fujifilm XT3, long shot, ((low light:1.4)), ((looking straight at the camera:1.3)), upper body shot, somber, shallow depth of field, vignette, highly detailed, high budget Hollywood movie, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
12    "negative_prompt": "ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft",
13    "style": "base",
14    "samples": 1,
15    "scheduler": "UniPC",
16    "num_inference_steps": 25,
17    "guidance_scale": 8,
18    "strength": 0.2,
19    "high_noise_fraction": 0.8,
20    "seed": 468685,
21    "img_width": 896,
22    "img_height": 1152,
23    "refiner": true,
24    "base64": false
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/sdxl1.0-txt2imgParameters
promptrequiredstringPrompt to render
base64optionalbooleanBase64 encoding of the output image.
falseguidance_scaleoptionalnumberScale for classifier-free guidance
7.5Range: 1 - 25high_noise_fractionoptionalnumberNumber of inference steps to be run on each expert
0.8Range: 0 - 1img_heightoptionalintegerImage height can be between 512 and 2048 in multiples of 8
1024img_widthoptionalintegerImage width can be between 512 and 2048 in multiples of 8
1024negative_promptoptionalstringPrompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'
num_inference_stepsoptionalintegerNumber of denoising steps.
25Range: 20 - 100refineroptionalbooleanIf yes, improves the quality of the output. Note: Does not work when high noise fraction is 1.
truesamplesoptionalintegerNumber of samples to generate.
1Range: 1 - 4scheduleroptionalstringType of scheduler.
"UniPC""DDIM""DPM Multi""DPM Single""Euler a""Euler""Heun""DPM2 a Karras""DPM2 Karras""LMS""PNDM"+2 moreseedoptionalintegerSeed for image generation.
-1Range: -1 - 999999999999999strengthoptionalnumberHow much to transform the reference image
0.2Range: 0.1 - 1styleoptionalstringStyles for Stable Diffusion.
"base""base""3d-model""analog film""anime""cinematic""comic book""craft clay""digital art""enhance""fantasy art"+94 moreResponse 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