SDXL Lightning API Documentation

Get Image - Request Code

POST https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage Ocp-Apim-Subscription-Key: your-subscription-key-here Content-Type: application/json { "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 }
import requests url = "https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage" headers = { "Ocp-Apim-Subscription-Key": "your-subscription-key-here", "Content-Type": "application/json" } data = { "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 } response = requests.post(url, json=data, headers=headers) print(response.json())
const url = "https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage"; const headers = { "Ocp-Apim-Subscription-Key": "your-subscription-key-here", "Content-Type": "application/json" }; const data = { "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 }; fetch(url, { method: "POST", headers: headers, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error("Error:", error));
curl -X POST "https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage" \ -H "Ocp-Apim-Subscription-Key: your-subscription-key-here" \ -H "Content-Type: application/json" \ -d '{ "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 }'
import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; public class ApiExample { public static void main(String[] args) throws Exception { String url = "https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage"; String json = """ { "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 } """; HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Ocp-Apim-Subscription-Key", "your-subscription-key-here") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } }
<?php $url = 'https://gateway-stable-diffusion-xl-lightning.appypie.workers.dev/getSDXLImage'; $headers = [ 'Ocp-Apim-Subscription-Key: your-subscription-key-here', 'Content-Type: application/json', ]; $data = json_encode([ 'prompt' => 'High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.', 'negativePrompt' => 'Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.', 'height' => 1024, 'width' => 1024, 'num_steps' => 20, 'guidance' => 5, 'seed' => 42 ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch); echo $response; ?>

Output

Successful API response:

{ "imageUrl": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/sdxl_lightning/prompt-355182775-1724841428119-422172.png" }

Request Body - Get Image

Parameters for /getSDXLImage:

ParameterRequiredTypeDescription
PromptYesStringThe main instruction for the image transformation ("High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.").
Negative PromptNoStringA prompt to specify what should be avoided in the image ("Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.").
HeightNoIntegerThe height of the output image (1024).
WidthNoIntegerThe width of the output image (1024).
Num StepsNoIntegerThe number of steps for the transformation process (20).
GuidanceNoIntegerThe guidance scale for the transformation (5).
SeedNoIntegerThe seed value for random number generation to ensure reproducibility (42).

Example Request - Get Image

JSON
{ "prompt": "High-resolution, realistic image of a sparrow bird perched on a blooming cherry blossom branch during springtime. The sparrow's feathers should be finely detailed with natural colors, including shades of brown and white. The background should be soft-focused with a clear blue sky, creating a serene and peaceful atmosphere.", "negativePrompt": "Low-quality, blurry image, with any other birds or animals. Avoid abstract or cartoonish styles, dark or gloomy atmosphere, unnecessary objects or distractions in the background, harsh lighting, and unnatural colors.", "height": 1024, "width": 1024, "num_steps": 20, "guidance": 5, "seed": 42 }

Response - Get Image

JSON
{ "imageUrl": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/sdxl_lightning/prompt-355182775-1724841428119-422172.png" }

Request Headers

HeaderDescription
Ocp-Apim-Subscription-KeySubscription key for API authentication
Content-TypeMust be set to application/json

Response Handling

The Stable Diffusion XL Lightning returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement error handling in their applications to manage these responses effectively.

Common Status Codes and Responses

Status CodeDescriptionResponse Body
200Success - The request was successfully processed.{ "success": true, ... }
Bad Request - The request contains invalid parameters or missing fields.{ "error": "Invalid request parameters" }
401Unauthorized - The provided subscription key is missing or invalid.{ "error": "Invalid or missing authentication" }
403Forbidden - The subscription does not have access to this API or action.{ "error": "Access denied for this operation" }
404Not Found - The requested resource or endpoint could not be found.{ "error": "Endpoint not found" }
Too Many Requests - The request rate limit has been exceeded.{ "error": "Rate limit exceeded, please retry later" }
500Internal Server Error - An unexpected error occurred on the server.{ "error": "An unexpected error occurred, please try again later" }

Example Error Response

{ "error": "Invalid parameters" }

Retrieving Image Result and URL

After submitting your request, use this endpoint to check status and retrieve results.

Endpoint

POST https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults

Request Body

{ "job_set_id": "your-job-set-id-here" }

Response

{ "status": "completed", "imageUrl": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/sdxl_lightning/prompt-355182775-1724841428119-422172.png", "job_set_id": "your-job-set-id-here" }

Code Examples

POST https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults Ocp-Apim-Subscription-Key: your-subscription-key-here Content-Type: application/json { "job_set_id": "your-job-set-id-here" }
import requests url = "https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults" headers = { "Ocp-Apim-Subscription-Key": "your-subscription-key-here", "Content-Type": "application/json" } data = { "job_set_id": "your-job-set-id-here" } response = requests.post(url, json=data, headers=headers) print(response.json())
const url = "https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults"; const headers = { "Ocp-Apim-Subscription-Key": "your-subscription-key-here", "Content-Type": "application/json" }; const data = { "job_set_id": "your-job-set-id-here" }; fetch(url, { method: "POST", headers: headers, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error("Error:", error));
curl -X POST "https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults" \ -H "Ocp-Apim-Subscription-Key: your-subscription-key-here" \ -H "Content-Type: application/json" \ -d '{ "job_set_id": "your-job-set-id-here" }'
import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; public class PollingExample { public static void main(String[] args) throws Exception { String url = "https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults"; String json = """ { "job_set_id": "your-job-set-id-here" } """; HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Ocp-Apim-Subscription-Key", "your-subscription-key-here") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } }
<?php $url = 'https://gateway.pixazo.ai/ai-model-api-polling/getGenerationResults'; $headers = [ 'Ocp-Apim-Subscription-Key: your-subscription-key-here', 'Content-Type: application/json', ]; $data = json_encode([ 'job_set_id' => 'your-job-set-id-here' ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch); echo $response; ?>

SDXL Lightning API Pricing

Resolution Price (USD)
All ResolutionFree