stabilityai/stable-diffusion-2-1 cover image

stabilityai/stable-diffusion-2-1

Stable Diffusion is a latent text-to-image diffusion model. Generate realistic images given text description

Stable Diffusion is a latent text-to-image diffusion model. Generate realistic images given text description

Public

OpenAI-compatible HTTP API

This document provides an overview of the DeepInfra-compatible OpenAI image generation API. It allows users to generate AI-created images based on text prompts using DeepInfra models.

Image Generation

https://api.deepinfra.com/v1/openai/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DEEPINFRA_TOKEN" \
  -d '{
    "prompt": "A photo of an astronaut riding a horse on Mars.",
    "size": "1024x1024",
    "model": "stabilityai/stable-diffusion-2-1",
    "n": 1
    }'

The API returns a JSON object containing the generated image(s).

Example Response

{
  "created": 1707000000,
  "data": [
    {
      "revised_prompt": "A photo of an astronaut riding a horse on Mars.",
      "b64_json": "https://..."
    }
  ]
}

Input fields

promptstring

A text description of desired image(s).


modelstring

The model to use for image generation.

Default value: "black-forest-labs/FLUX-1-schnell"


ninteger

The number of images to generate.

Default value: 1

Range: 1 ≤ n ≤ 4


qualitystring

The quality of the image that will be generated.


response_formatstring

The format in which the generated images are returned. Currently only b64_json is supported.

Default value: "b64_json"

Allowed values: b64_json


sizestring

The size of the generated images. Available sizes depend on the model.

Default value: "1024x1024"


stylestring

The style of the generated images.'


userstring

A unique identifier representing your end-user, which can help to monitor and detect abuse.

Input Schema

Output Schema