# SDXL Lightning 4-step > SDXL-Lightning is a lightning-fast text-to-image generation model that produces high-quality 1024px images in just a few steps, distilled from Stable Diffusion XL. ## Overview - **Endpoint**: `https://queue.modelrunner.run/bytedance/sdxl-lightning-4step` - **Model ID**: `bytedance/sdxl-lightning-4step` - **Category**: text-to-image - **Kind**: inference - **Tags**: image, text, image generator ## Pricing - **Estimated Price**: $0.00251692 average per output ## Request Lifecycle This model runs on the ModelRunner **asynchronous queue API** — a single POST does not return the output. Every call requires an `Authorization: Key $MODEL_RUNNER_KEY` header. Run three steps: 1. **Submit** — `POST https://queue.modelrunner.run/bytedance/sdxl-lightning-4step` with a JSON body holding the input fields at the top level. The body may also include a reserved top-level `metadata` object — a flat string map (max 16 keys, key ≤64 / value ≤512 chars) stored on the request for your own tagging. It is never sent to the model; filter your request history with `GET https://queue.modelrunner.run/requests?metadata=` (exact key=value matches, AND-ed). The response carries request handles only (no output yet): ```json { "status": "IN_QUEUE", "request_id": "<21-char id>", "status_url": "https://queue.modelrunner.run/bytedance/sdxl-lightning-4step/requests//status", "response_url": "https://queue.modelrunner.run/bytedance/sdxl-lightning-4step/requests/", "cancel_url": "https://queue.modelrunner.run/bytedance/sdxl-lightning-4step/requests//cancel" } ``` 2. **Poll status** — `GET ` until `status` is `COMPLETED`. Possible values are `IN_QUEUE`, `IN_PROGRESS`, `COMPLETED`, `FAILED`, `CANCELLED`. A `FAILED` request responds with HTTP 400 and an `error` field. 3. **Read result** — `GET `. Returns the finished request, including the generated `output`: ```json { "id": "", "status": "COMPLETED", "output": ..., "input": ... } ``` The JavaScript and Python SDKs below perform steps 2–3 for you. In any language without an SDK (Swift, Go, Kotlin, etc.) you must implement the polling loop and the final result fetch yourself — see the cURL example for the full flow. ### Input Schema - **`seed`** (`integer`, _optional_): Random seed. Leave blank to randomize the seed - Default: `0` - **`width`** (`integer`, _optional_): Width of output image. Recommended 1024 or 1280 - Default: `1024` - Range: `256` to `1280` - **`height`** (`integer`, _optional_): Height of output image. Recommended 1024 or 1280 - Default: `1024` - Range: `256` to `1280` - **`prompt`** (`string`, _optional_): Input prompt - Default: `"self-portrait of a woman, lightning in the background"` - **`scheduler`** (`scheduler`, _optional_): scheduler - Default: `"K_EULER"` - Options: `"DDIM"`, `"DPMSolverMultistep"`, `"HeunDiscrete"`, `"KarrasDPM"`, `"K_EULER_ANCESTRAL"`, `"K_EULER"`, `"PNDM"`, `"DPM++2MSDE"` - **`num_outputs`** (`integer`, _optional_): Number of images to output. - Default: `1` - Range: `1` to `4` - **`guidance_scale`** (`number`, _optional_): Scale for classifier-free guidance - Default: `0` - Range: `0` to `50` - **`negative_prompt`** (`string`, _optional_): Negative Input prompt - Default: `"worst quality, low quality"` - **`num_inference_steps`** (`integer`, _optional_): Number of denoising steps. 4 for best results - Default: `4` - Range: `1` to `10` - **`disable_safety_checker`** (`boolean`, _optional_): Disable safety checker for generated images - Default: `false` ### Output Schema _No `Output` schema properties are available._ ## Default Example **Input** ```json { "seed": 102, "width": 1280, "height": 1024, "prompt": "luxury stainless-steel chronograph wristwatch on black marble, dramatic rim lighting and softbox reflections, macro 1:1, product hero shot, crisp edges, sharp engraving, studio setup, minimal composition, photoreal", "scheduler": "K_EULER", "num_outputs": 1, "guidance_scale": 0, "negative_prompt": "worst quality, low quality, noise, blurry, fingerprints, dust, scratched glass, watermark, text, logo", "num_inference_steps": 4, "disable_safety_checker": false } ``` **Output** ```json [ "https://media.modelrunner.ai/xjIJl31UMHQUfUtkMu9Dn.png" ] ``` ## Usage Examples ### cURL The queue API is asynchronous: submit the request, poll `status_url` until it is `COMPLETED`, then read the result from `response_url`. Requires `jq`. ```bash # 1. Submit the request (returns request handles, not the output) SUBMIT=$(curl --silent --request POST \ --url https://queue.modelrunner.run/bytedance/sdxl-lightning-4step \ --header "Authorization: Key $MODEL_RUNNER_KEY" \ --header "Content-Type: application/json" \ --data '{ "seed": 102, "width": 1280, "height": 1024, "prompt": "luxury stainless-steel chronograph wristwatch on black marble, dramatic rim lighting and softbox reflections, macro 1:1, product hero shot, crisp edges, sharp engraving, studio setup, minimal composition, photoreal", "scheduler": "K_EULER", "num_outputs": 1, "guidance_scale": 0, "negative_prompt": "worst quality, low quality, noise, blurry, fingerprints, dust, scratched glass, watermark, text, logo", "num_inference_steps": 4, "disable_safety_checker": false }') STATUS_URL=$(echo "$SUBMIT" | jq -r '.status_url') RESPONSE_URL=$(echo "$SUBMIT" | jq -r '.response_url') # 2. Poll until the request leaves the queue / in-progress state while true; do STATUS=$(curl --silent --url "$STATUS_URL" \ --header "Authorization: Key $MODEL_RUNNER_KEY" | jq -r '.status') echo "Status: $STATUS" case "$STATUS" in COMPLETED) break ;; FAILED|CANCELLED) echo "Request $STATUS"; exit 1 ;; esac sleep 1 done # 3. Read the finished request, including the generated output curl --silent --url "$RESPONSE_URL" \ --header "Authorization: Key $MODEL_RUNNER_KEY" ``` ### JavaScript ```javascript import { modelrunner } from "@modelrunner/client"; const result = await modelrunner.subscribe("bytedance/sdxl-lightning-4step", { input: { "seed": 102, "width": 1280, "height": 1024, "prompt": "luxury stainless-steel chronograph wristwatch on black marble, dramatic rim lighting and softbox reflections, macro 1:1, product hero shot, crisp edges, sharp engraving, studio setup, minimal composition, photoreal", "scheduler": "K_EULER", "num_outputs": 1, "guidance_scale": 0, "negative_prompt": "worst quality, low quality, noise, blurry, fingerprints, dust, scratched glass, watermark, text, logo", "num_inference_steps": 4, "disable_safety_checker": false } }); console.log(result.data); ``` ### Python ```python import asyncio import modelrunner_ai async def main(): response = await modelrunner_ai.submit_async( "bytedance/sdxl-lightning-4step", arguments={ "seed": 102, "width": 1280, "height": 1024, "prompt": "luxury stainless-steel chronograph wristwatch on black marble, dramatic rim lighting and softbox reflections, macro 1:1, product hero shot, crisp edges, sharp engraving, studio setup, minimal composition, photoreal", "scheduler": "K_EULER", "num_outputs": 1, "guidance_scale": 0, "negative_prompt": "worst quality, low quality, noise, blurry, fingerprints, dust, scratched glass, watermark, text, logo", "num_inference_steps": 4, "disable_safety_checker": false } ) result = await response.get() print(result["output"]) asyncio.run(main()) ``` ## Additional Resources - [Playground](https://modelrunner.ai/models/bytedance/sdxl-lightning-4step) - [OpenAPI Schema](https://modelrunner.ai/models/bytedance/sdxl-lightning-4step/openapi.json) - [LLM Instructions](https://modelrunner.ai/models/bytedance/sdxl-lightning-4step/llms.txt) - [GitHub](https://github.com/lucataco/cog-sdxl-lightning-4step) - [License](https://huggingface.co/ByteDance/SDXL-Lightning/blob/main/LICENSE.md) - [Weights](https://huggingface.co/ByteDance/SDXL-Lightning) - [Paper](https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_report.pdf)