Deploying and using Stable Diffusion XL 1.0

Stable Diffusion XL 1.0 is a highly capable text-to-image model by Stability AI that was released on July 26, 2023 under their CreativeML Open RAIL++-M license.

Deploy Stable Diffusion XL 1.0

You can deploy Stable Diffusion XL 1.0 in 2 clicks from Baseten’s model library. It’s also available packaged as a Truss on GitHub.

Hardware requirements

Stable Diffusion XL requires an A100 for invocation. In our testing, it takes 8-12 seconds to generate an image.

Manual deployment

Sign up or sign in to your Baseten account and create an API key. Then run:

git clone
pip install --upgrade baseten
baseten login

Paste your API key when prompted.

Once authenticated, in an iPython notebook, run the following script to deploy SDXL to your Baseten account:

import baseten
import truss

sdxl = truss.load("truss-examples/sdxl-1.0/")
  model_name="Stable Diffusion XL 1.0"

Use Stable Diffusion XL 1.0

This model is capable of generating stunningly detailed and accurate images from simple prompts.

To invoke the model, run:

import baseten

# You can retrieve your deployed model version ID from the UI
model = baseten.deployed_model_version_id('MODEL_VERSION_ID')

request = {
    "prompt": "A tree in a field under the night sky",
    "use_refiner": True

response = model.predict(request)

The output will be a dictionary with a key data mapping to a base64 encoded image. You can save the image with the following snippet:

import base64


img_file = open('image.jpeg', 'wb')

The Stable Diffusion Refiner model

The Stable Diffusion Refiner model adds accuracy to difficult-to-generate details like facial features and hands. You can choose whether or not to use the refiner model in an invocation with the use_refiner parameter.

Example outputs

Prompt: A tree in a field under the night sky
Prompt: A portrait in the style of Andy Warhol of George Washington incredibly detailed
Prompt: A wise old wizard summons a flock of birds hd cinematic colorful

Reach out to us at with any questions!

Machine learning infrastructure that just works

Baseten provides all the infrastructure you need to deploy and serve ML models performantly, scalable, and cost-efficiently.

Machine Learning

NVIDIA A10 vs A100 GPUs for LLM and Stable Diffusion inference

This article compares two popular GPUs—the NVIDIA A10 and A100—for model inference and discusses the option of using multi-GPU instances for larger models.

Philip Kiely

September 15, 2023

Machine Learning

SDXL inference in under 2 seconds: the ultimate guide to Stable Diffusion optimization

Out of the box, Stable Diffusion XL 1.0 (SDXL) takes 8-10 seconds to create a 1024x1024px image from a prompt on an A100 GPU. Here’s everything I did to cut SDXL invocation to as fast as 1.92 seconds on an A100.

Varun Shenoy

August 30, 2023