Stability.Ai
  1. generation
Stability.Ai
  • Getting Started
  • v1
    • user
      • account
      • balance
    • engines
      • list
    • generation
      • text-to-image
        POST
      • image-to-image
        POST
      • image-to-image/upscale
        POST
      • image-to-image/masking
        POST
  • v2alpha
    • generation
      • image-to-video
      • image-to-video/result
      • stable-image/upscale
      • stable-image/upscale/result
      • stable-image/inpaint
  1. generation

text-to-image

https://api.stability.ai
https://api.stability.ai
https://api.stability.ai
https://api.stability.ai
POST
/v1/generation/{engine_id}/text-to-image
v1/generation
Generate a new image from a text prompt
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image' \
--header 'Content-Type: application/json' \
--data-raw '{
    "cfg_scale": 7,
    "clip_guidance_preset": "FAST_BLUE",
    "height": 512,
    "width": 512,
    "sampler": "K_DPM_2_ANCESTRAL",
    "samples": 1,
    "steps": 30,
    "text_prompts": [
        {
            "text": "A lighthouse on a cliff",
            "weight": 1
        }
    ]
}'
Response Response Example
200 - Example 1
{
    "artifacts": [
        [
            {
                "base64": "...very long string...",
                "finishReason": "SUCCESS",
                "seed": 1050625087
            },
            {
                "base64": "...very long string...",
                "finishReason": "CONTENT_FILTERED",
                "seed": 1229191277
            }
        ]
    ]
}

Request

Path Params
engine_id
string 
required
Example:
stable-diffusion-v1-6
Header Params
Accept
string 
optional
The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image.
Organization
string 
optional
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.
Example:
org-123456
Stability-Client-ID
string 
optional
Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity.
Example:
my-great-plugin
Stability-Client-Version
string 
optional
Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity.
Example:
1.2.1
Body Params application/json
Represents the optional parameters that can be passed to any generation request.
height
integer 
DiffuseImageHeight
optional
Height of the image to generate, in pixels, in an increment divible by 64.
Engine-specific dimension validation:
SDXL Beta: must be between 128x128 and 512x896 (or 896x512); only one dimension can be greater than 512.
SDXL v0.9: must be one of 1024x1024, 1152x896, 1216x832, 1344x768, 1536x640, 640x1536, 768x1344, 832x1216, or 896x1152
SDXL v1.0: same as SDXL v0.9
SD v1.6: must be between 320x320 and 1536x1536
>= 128
Default:
512
Example:
512
Multiple of:
64
width
integer 
DiffuseImageWidth
optional
Width of the image to generate, in pixels, in an increment divible by 64.
Engine-specific dimension validation:
SDXL Beta: must be between 128x128 and 512x896 (or 896x512); only one dimension can be greater than 512.
SDXL v0.9: must be one of 1024x1024, 1152x896, 1216x832, 1344x768, 1536x640, 640x1536, 768x1344, 832x1216, or 896x1152
SDXL v1.0: same as SDXL v0.9
SD v1.6: must be between 320x320 and 1536x1536
>= 128
Default:
512
Example:
512
Multiple of:
64
text_prompts
array[object (TextPrompt) {2}] 
TextPrompts
required
An array of text prompts to use for generation.
Given a text prompt with the text A lighthouse on a cliff and a weight of 0.5, it would be represented as:
"text_prompts": [
  {
    "text": "A lighthouse on a cliff",
    "weight": 0.5
  }
]
>= 1 items
text
string 
required
The prompt itself
<= 2000 characters
Example:
A lighthouse on a cliff
weight
number <float>
optional
Weight of the prompt (use negative numbers for negative prompts)
Example:
0.8167237
cfg_scale
number 
CfgScale
optional
How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)
>= 0<= 35
Default:
7
Example:
7
clip_guidance_preset
enum<string> 
ClipGuidancePreset
optional
Allowed values:
FAST_BLUEFAST_GREENNONESIMPLESLOWSLOWERSLOWEST
Default:
NONE
Example:
FAST_BLUE
sampler
enum<string> 
Sampler
optional
Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you.
Allowed values:
DDIMDDPMK_DPMPP_2MK_DPMPP_2S_ANCESTRALK_DPM_2K_DPM_2_ANCESTRALK_EULERK_EULER_ANCESTRALK_HEUNK_LMS
Example:
K_DPM_2_ANCESTRAL
samples
integer 
Samples
optional
Number of images to generate
>= 1<= 10
Default:
1
Example:
1
seed
integer 
Seed
optional
Random noise seed (omit this option or use 0 for a random seed)
>= 0<= 4294967295
Default:
0
Example:
0
steps
integer 
Steps
optional
Number of diffusion steps to run.
>= 10<= 50
Default:
30
Example:
50
style_preset
enum<string> 
StylePreset
optional
Pass in a style preset to guide the image model towards a particular style.
This list of style presets is subject to change.
Allowed values:
3d-modelanalog-filmanimecinematiccomic-bookdigital-artenhancefantasy-artisometricline-artlow-polymodeling-compoundneon-punkorigamiphotographicpixel-arttile-texture
extras
object 
Extras
optional
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.
Examples

Responses

🟢200Success
application/json
Body
An array of results from the generation request, where each image is a base64 encoded PNG.
artifacts
array[object (Image) {3}] 
optional
base64
string 
optional
Image encoded in base64
finishReason
enum<string> 
optional
Allowed values:
CONTENT_FILTEREDERRORSUCCESS
Example:
CONTENT_FILTERED
seed
number 
optional
The seed associated with this image
Example:
1229191277
🟠400400
🟠401401
🟠403403
🟠404404
🔴500500
Previous
list
Next
image-to-image
Built with