back to the blog

How to use Stable Diffusion API

Written on . Posted in Stable Diffusion API.
How to use Stable Diffusion API

Here is 4 step process to generate images using stable diffusion API

 

  1.  
    1. Get the API key from stablediffusionapi.com
    2. Verify Parameters
    3. Make API call
    4. Get Generated Image

 

1. Get the API key

Get a stable diffusion API key
Get a stable diffusion API key

 

In order to get the API key, register to stablediffusionapi.com You will get the API key after you register on the platform, Copy this and keep it in a safe place. this will be required later to generate images.

You can generate new API keys as well as per your needs. 

 

2. Verify Parameters

  

Following are the parameters which you can pass to stable diffusion API

key
 

Your API Key here

prompt
medium shot side profile portrait photo of the Takeshi Kaneshiro warrior chief, tribal panther make-up, blue on red, looking away, serious eyes, 50mm portrait, photography, hard rim lighting photography –ar 2:3 –beta –upbeta

Input prompt

width
 

Width of the output image. The maximum size is 1024x768 or 768x1024 because of memory limits

height
 

Height of output image. The maximum size is 1024x768 or 768x1024 because of memory limits

init_image
 

Initial image to generate variations of. Will be resized to the specified width and height

mask
 

Black and white image to use as a mask for inpainting over init_image. Black pixels are inpainted and white pixels are preserved. Experimental feature tends to work better with prompt strength of 0.5-0.7

prompt_strength
 

Prompt strength when using init image. 1.0 corresponds to the full destruction of information in the init image

num_inference_steps
30

Number of denoising steps

guidance_scale
 

Scale for classifier-free guidance

seed
 

Random seed. Leave blank to randomize the seed 

 

3. Make API Call

You can use Curl, or an HTTP API call library to make an API call. You can find all sample codes in the documentation URL

 

https://documenter.getpostman.com/view/18679074/2s83zdwReZ

 

4. Get Generated Image

If all is good, you will get generated image in response, it will be an image link that you can download or see in the browser