Stable Diffusion APIs

Stable Diffusion APIs

Venkat Raman's photo
Venkat Raman
·Dec 6, 2022·

4 min read

Play this article

Generative AI

Generative AI is taking the tech and non-tech world by storm. ChatGPT anyone? To that end we started providing APIs for Stable diffusion in September. Stable diffusion image generation models are a type of machine learning model that can be used to generate images based on a given set of input data. These models have become increasingly popular due to their ability to create highly realistic and detailed images that can be used for a variety of purposes. Our stable of stable diffusion models (pun intended) has grown from a single model to multiple models for various tasks like text to image, image to image and inpainting. We also provide multiple versions of these models to our users.

Our goal is to enable developers to ‘consume’ these latest innovations in AI as a service. By using stable diffusion image generation models as APIs, developers can significantly reduce the time and effort required to build and deploy their applications. This allows them to focus on building the core features and functionality of their applications, rather than spending time and resources on building and maintaining the underlying image generation infrastructure.

We have diffusion models for

  • Text To Image
  • Image to Image
  • Inpainting

The following versions of the above models are available

Text To ImageImage to ImageInpainting

Models as API

Before we get into the details of the diffusion models I would like to mention that all models that are offered as an API on Tiyaro are documented with Swagger or OpenAPI specification. This allows you to find out all the input parameters that are supported by these API endpoints along with the supported values for those parameters. This is especially useful for Stable Diffusion models because each version supports its own schedulers and you can quickly find those out from the swagger spec (see the gif below). We also provide working code samples in the model card for each model as well as a code samples git repo.


Stable Diffusion Models

Text To Image

This model takes a user prompt and generates an image based on the input prompt. Here is a sample Python program that inovkes the 2.0 version of this API. You can also clone the following code from our code sample repo.

import requests
import os
import sys
import io
from PIL import Image
import json
import base64

# You can generate your Tiyaro API Key from here
apikey = os.getenv("TIYARO_API_KEY")
if apikey is None:
    print("Please set env variable TIYARO_API_KEY")
    print("You can generate your API key from")

headers = {
    "Authorization": f"Bearer {apikey}",
    "content-type": "application/json"
url = ""
querystring = {"serviceTier": "gpuflex"}

# Credit for the prompt goes to this reddit post
payload = {"input": {
    "prompt": "Cinematic shot of taxidermy bird inside an antique shop, glass, crystal, flowers, loxurious,",
    "negative_prompt": "Photoshop, video game, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, mutation, mutated, extra limbs, extra legs, extra arms, disfigured, deformed, cross-eye, body out of frame, blurry, bad art, bad anatomy, 3d render,",
    "scheduler": "dpm",
    "disable_safety_checker": False,
    "seed": 3813511178,
    "steps": 20,
    "guidance_scale": 12.1,
    "width": 512,
    "height": 512

response = requests.request(
    "POST", url, json=payload, headers=headers, params=querystring)

resp = json.loads(response.text)
imgB64 = resp["response"]["images"][0]
imgData = base64.b64decode(imgB64)

im =

Here is the image generated by the above code. The credit for the prompt goes to this reddit post


Image to Image

This is a model that does image to image translation guided by the user prompts. Here is an example of that model in use from the Tiyaro UI.



This method takes an image and an image mask, the model is then able to place the masked part of the image into a setting described by the text. See following example.


Find Stable Diffusion on Tiyaro

You can simply search for 'stable diffusion' in Search and you will get a listing of all the above 3 types of models for each version.

Dreambooth - Customize diffusion models for your needs

In addition to the models described above, we also provide Dreambooth training as a service. Dreambooth allows users to train diffusion models for their specific use case. We offer Dreambooth training in 2 ways

  • From the UI
  • Dreambooth training as API

You can refere to the step-by-step blog on how to train diffusion models using our UI.

A much requested feature, the API for dreambooth is documented here. This is the goto option for developers who are trying to use retraining in their workflows.


There are a variety of ready to use APIs available for developers to both use and train Diffusion models on Tiyaro. Simply signup and give it a go!

Share this