In this tutorial, you will learn how to deploy a endpoint running Stable Diffusion XL (SDXL) on Runpod, submit image jobs, monitor their progress, and decode the resulting images. Runpod’s Serverless platform allows you to run AI/ML models in the cloud without managing infrastructure, automatically scaling resources as needed. SDXL is a powerful AI model that generates high-quality images from text prompts.Documentation Index
Fetch the complete documentation index at: https://runpod-b18f5ded-promptless-remove-flash-beta-notification.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
Before starting this tutorial you’ll need:- A Runpod account with available credits.
- A Runpod API key (available in your user settings).
- Basic familiarity with command-line tools like
curl. - Python installed on your system (for the image decoding step).
- The
jqcommand-line JSON processor (optional but recommended).
Step 1: Deploy a Serverless endpoint using the Runpod Hub
- Navigate to the SDXL listing in the Runpod Hub web interface.
- Click Deploy [VERSION_NUMBER], then click Create Endpoint to confirm. This creates a fully configured endpoint with appropriate GPU and worker settings for running SDXL.
This tutorial uses version 2.1.0 of runpod-workers/worker-sdxl. Later versions may require different configurations or instructions.
- On the endpoint page, make a note of the Endpoint ID . You’ll need this value to submit jobs and retrieve results.
32vgrms732dkwi). Your endpoint URL will follow this pattern: https://api.runpod.ai/v2/ENDPOINT_ID/run for asynchronous requests.
Step 2: Submit your first job
Use the/run endpoint to submit an asynchronous job that will generate an image based on your text prompt.
Replace ENDPOINT_ID with your actual endpoint ID and YOUR_API_KEY with your Runpod API key in the following command:
Step 3: Monitor job progress
Check your job’s status using the/status endpoint with the job ID you received in the previous step.
Use the following command to check your job’s progress, replacing the placeholders (ENDPOINT_ID, JOB_ID, and YOUR_API_KEY) with your actual values:
delayTime field shows how long the job waited in the queue before processing began, measured in milliseconds.
Step 4: Retrieve completed results
Continue polling this endpoint until the status changes toCOMPLETED. Once your job completes, the status endpoint will return the generated image data encoded in base64 format.
When your job finishes successfully, you’ll receive a response containing the output:
executionTime field shows how long the actual image generation took, while delayTime indicates the initial queue wait time. Both values are in milliseconds.
To save the complete response for processing, use this command:
Step 5: Decode and save your image
Now we’ll convert the base64-encoded image data into a viewable image file using Python. Create a Python script calleddecode_image.py to decode the base64 image data from your JSON response:
Congratulations! You’ve successfully used Runpod’s Serverless platform to generate an AI image using SDXL. You now understand the complete workflow of submitting asynchronous jobs, monitoring their progress, and retrieving results.
Next steps
Now that you’ve learned how to generate images with Serverless, consider exploring these advanced topics:- Learn how to create synchronous requests using the
/runsyncendpoint for faster responses. - Explore endpoint configurations to optimize performance and cost.
- Discover how to send requests with advanced parameters and webhook notifications.
- Try deploying your own custom worker for specialized AI models.