2 minutes to read - Mar 30, 2023

Stable Diffusion Guide: How to use our Stable Diffusion API

VISIT
Stable Diffusion Guide: How to use our Stable Diffusion API
This article is to provide an overview of the API that was available for the Stable Diffusion Hackathon. Please note that this API is no longer available!
Table of Contents
1Short introduction to Stable Diffusion
2Lets get started

This tutorial shows you how to use our Stable Diffusion API to generate images in seconds. We created our own to ease the development of your project. You cam simply call the endpoint with your prompt, for example "A cat with a hat" and get back a link to the generated image. You can then continue working with the image. We provide a lot of different code examples in different programming languages in this guide.

Short introduction to Stable Diffusion

Stable Diffusion is a text-to-image latent diffusion model created by the researchers and engineers from CompVis, Stability AI and LAION. It's trained on 512x512 images from a subset of the LAION-5B database. This model uses a frozen CLIP ViT-L/14 text encoder to condition the model on text prompts. With its 860M UNet and 123M text encoder, the model is relatively lightweight. If you want to learn more continue reading on our Stable Diffusion tech page here.

Lets get started

You can call the API from your Python project with the help of the requests module like this:

If you need the image on your local disk you can use the following code to download it from the URL (Python)

In Javascript you can call the API with this code:

and how to call the endpoint in C#:

If you are building a flutter app you might want to use Dart to call the API. Here is how you can do it:

Note that you can change the actual prompt to whatever you want in the URL parameter.

Article source
loading...