v6

latestOpenAPI 3.0.3raw.githubusercontent.com2025-03-0663270.5 KB
Version1.Image

Text-to-image

Generate an image from a text prompt.

Using SDXL 1.0

Use stable-diffusion-xl-1024-v1-0 as the engine_id of your request and pass in height & width as one of the following combinations:

  • 1024x1024 (default)
  • 1152x896
  • 896x1152
  • 1216x832
  • 1344x768
  • 768x1344
  • 1536x640
  • 640x1536

SDXL 1.0 Pricing

When specifying 30 steps or fewer, generation costs 0.9 credits.

When specifying above 30 steps, generation cost is determined using the following formula:

cost = 0.9 * (steps / 30)

Using SD 1.6

SD1.6 is a flexible-resolution base model allowing you to generate non-standard aspect ratios. The model is optimized for a resolution of 512 x 512 pixels. To generate 1 megapixel outputs, we recommend using SDXL 1.0, which is available at the same price.

Pass in stable-diffusion-v1-6 as the engine_id of your request and ensure the height & width you pass in adhere to the following restrictions:

  • No dimension can be less than 320 pixels
  • No dimension can be greater than 1536 pixels
  • Height and width must be specified in increments of 64
  • The default resolution is 512 x 512
post/v1/generation/{engine_id}/text-to-image

Path parameters

engine_idstring required

Headers

Organizationstring

Allows for requests to be scoped to an organization other than the user's default. If not provided, the user's default organization will be used.

Stability-Client-IDstring

Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity.

Stability-Client-Versionstring

Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity.

Request body

heightinteger

Height of the image to generate, in pixels, in an increment divisible by 64.

widthinteger

Width of the image to generate, in pixels, in an increment divisible by 64.

cfg_scalenumber

How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)

clip_guidance_preset'FAST_BLUE' | 'FAST_GREEN' | 'NONE' | 'SIMPLE' | 'SLOW' | 'SLOWER' | 'SLOWEST'
sampler'DDIM' | 'DDPM' | 'K_DPMPP_2M' | 'K_DPMPP_2S_ANCESTRAL' | 'K_DPM_2' | 'K_DPM_2_ANCESTRAL' | 'K_EULER' | 'K_EULER_ANCESTRAL' | 'K_HEUN' | 'K_LMS'

Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you.

samplesinteger

Number of images to generate

seedinteger

Random noise seed (omit this option or use 0 for a random seed)

stepsinteger

Number of diffusion steps to run.

style_preset'enhance' | 'anime' | 'photographic' | 'digital-art' | 'comic-book' | 'fantasy-art' | 'line-art' | 'analog-film' | 'neon-punk' | 'isometric' | 'low-poly' | 'origami' | 'modeling-compound' | 'cinematic' | '3d-model' | 'pixel-art' | 'tile-texture'

Pass in a style preset to guide the image model towards a particular style. This list of style presets is subject to change.

extrasExtras

Extra parameters passed to the engine. These parameters are used for in-development or experimental features and may change without warning, so please use with caution.

Example request

{
  "cfg_scale": 7,
  "height": 512,
  "width": 512,
  "sampler": "K_DPM_2_ANCESTRAL",
  "samples": 1,
  "seed": 0,
  "steps": 30,
  "text_prompts": [
    {
      "text": "A lighthouse on a cliff",
      "weight": 1
    }
  ]
}

Response

Generation successful.

Example response

{
  "artifacts": [
    {
      "finishReason": "CONTENT_FILTERED",
      "seed": 1229191277
    }
  ]
}
All 6 operations