Stable Diffusion XL 1.0 - Torch Serverless API
The SDXL model is the official upgrade to the v1.5 model. The model is released as open-source software
POST /v2/sdxl-torch · 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 "sdxl-torch",
9 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",
10 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",
11 style="base",
12 samples=1,
13 scheduler="UniPC",
14 num_inference_steps=25,
15 guidance_scale=8,
16 strength=0.2,
17 high_noise_fraction=0.8,
18 seed=468685,
19 img_width=1024,
20 img_height=1024,
21 refiner=True,
22 base64=False,
23)
24print(result["status"]) # COMPLETED
25print(result.get("output")) # model output (e.g. media URL)
26print(result["metrics"]["inference_time"]) # server compute seconds
27
28# --- Or submit + poll manually (track request_id, control the cadence) ---
29from segmind import SegmindClient, InferenceFailed, InferenceTimeout
30
31client = SegmindClient() # reads SEGMIND_API_KEY
32payload = {
33 "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",
34 "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",
35 "style": "base",
36 "samples": 1,
37 "scheduler": "UniPC",
38 "num_inference_steps": 25,
39 "guidance_scale": 8,
40 "strength": 0.2,
41 "high_noise_fraction": 0.8,
42 "seed": 468685,
43 "img_width": 1024,
44 "img_height": 1024,
45 "refiner": True,
46 "base64": False,
47}
48job = client.submit_async("sdxl-torch", **payload)
49print(job.request_id) # available immediately
50try:
51 result = job.wait(timeout=600, interval=1.0)
52except InferenceTimeout as e:
53 print("still running:", e.request_id)
54except InferenceFailed as e:
55 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 "sdxl-torch",
9 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",
10 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",
11 style="base",
12 samples=1,
13 scheduler="UniPC",
14 num_inference_steps=25,
15 guidance_scale=8,
16 strength=0.2,
17 high_noise_fraction=0.8,
18 seed=468685,
19 img_width=1024,
20 img_height=1024,
21 refiner=True,
22 base64=False,
23)
24print(result["status"]) # COMPLETED
25print(result.get("output")) # model output (e.g. media URL)
26print(result["metrics"]["inference_time"]) # server compute seconds
27
28# --- Or submit + poll manually (track request_id, control the cadence) ---
29from segmind import SegmindClient, InferenceFailed, InferenceTimeout
30
31client = SegmindClient() # reads SEGMIND_API_KEY
32payload = {
33 "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",
34 "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",
35 "style": "base",
36 "samples": 1,
37 "scheduler": "UniPC",
38 "num_inference_steps": 25,
39 "guidance_scale": 8,
40 "strength": 0.2,
41 "high_noise_fraction": 0.8,
42 "seed": 468685,
43 "img_width": 1024,
44 "img_height": 1024,
45 "refiner": True,
46 "base64": False,
47}
48job = client.submit_async("sdxl-torch", **payload)
49print(job.request_id) # available immediately
50try:
51 result = job.wait(timeout=600, interval=1.0)
52except InferenceTimeout as e:
53 print("still running:", e.request_id)
54except InferenceFailed as e:
55 print("failed:", e.detail)API Endpoint
https://api.segmind.com/v1/sdxl-torchParameters
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_heightoptionalintegerCan only be 1024 for SDXL
10241024img_widthoptionalintegerCan only be 1024 for SDXL
10241024negative_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
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/sdxl-torchSubmit — 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