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)

API Endpoint

POSThttps://api.segmind.com/v1/sdxl-torch

Parameters

promptrequired
string

Prompt to render

base64optional
boolean

Base64 encoding of the output image.

Default: false
guidance_scaleoptional
number

Scale for classifier-free guidance

Default: 7.5Range: 1 - 25
high_noise_fractionoptional
number

Number of inference steps to be run on each expert

Default: 0.8Range: 0 - 1
img_heightoptional
integer

Can only be 1024 for SDXL

Default: 1024
Allowed values :
1024
img_widthoptional
integer

Can only be 1024 for SDXL

Default: 1024
Allowed values :
1024
negative_promptoptional
string

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'

num_inference_stepsoptional
integer

Number of denoising steps.

Default: 25Range: 20 - 100
refineroptional
boolean

If yes, improves the quality of the output. Note: Does not work when high noise fraction is 1.

Default: true
samplesoptional
integer

Number of samples to generate.

Default: 1Range: 1 - 4
scheduleroptional
string

Type of scheduler.

Default: "UniPC"
Allowed values (12 total):
"DDIM""DPM Multi""DPM Single""Euler a""Euler""Heun""DPM2 a Karras""DPM2 Karras""LMS""PNDM"+2 more
seedoptional
integer

Seed for image generation.

Default: -1Range: -1 - 999999999999999
strengthoptional
number

How much to transform the reference image

Default: 0.2Range: 0.1 - 1
styleoptional
string

Styles for Stable Diffusion.

Default: "base"
Allowed values (104 total):
"base""3d-model""analog film""anime""cinematic""comic book""craft clay""digital art""enhance""fantasy art"+94 more

Response 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. 1
    POST /v2/sdxl-torch

    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