Download OpenAPI specification:Download
Welcome to the official Stability AI REST API!
You will need your Stability API key in order to make requests to this API.
Make sure you never share your API key with anyone, and you never commit it to a public repository. Include this key in
the Authorization
header of your requests.
This API is rate-limited to 150 requests every 10 seconds. If you exceed this limit, you will receive a 429
response.
If you find this limit too restrictive, please reach out to us via email at [email protected].
Check our Status Page to view the current health of our REST/gRPC APIs.
If you run into issues, please reach out to us:
Get information about the account associated with the provided API key
import os import requests api_host = os.getenv('API_HOST', 'https://api.stability.ai') url = f"{api_host}/v1/user/account" api_key = os.getenv("STABILITY_API_KEY") if api_key is None: raise Exception("Missing Stability API key.") response = requests.get(url, headers={ "Authorization": f"Bearer {api_key}" }) if response.status_code != 200: raise Exception("Non-200 response: " + str(response.text)) # Do something with the payload... payload = response.json()
{- "id": "user-1234",
- "organizations": [
- {
- "id": "org-5678",
- "name": "Another Organization",
- "role": "MEMBER",
- "is_default": true
}, - {
- "id": "org-1234",
- "name": "My Organization",
- "role": "MEMBER",
- "is_default": false
}
],
}
Get the credit balance of the account/organization associated with the API key
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
import os import requests api_host = os.getenv('API_HOST', 'https://api.stability.ai') url = f"{api_host}/v1/user/balance" api_key = os.getenv("STABILITY_API_KEY") if api_key is None: raise Exception("Missing Stability API key.") response = requests.get(url, headers={ "Authorization": f"Bearer {api_key}" }) if response.status_code != 200: raise Exception("Non-200 response: " + str(response.text)) # Do something with the payload... payload = response.json()
{- "credits": 0.6336833840314097
}
List all engines available to your organization/user
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
import os import requests api_host = os.getenv('API_HOST', 'https://api.stability.ai') url = f"{api_host}/v1/engines/list" api_key = os.getenv("STABILITY_API_KEY") if api_key is None: raise Exception("Missing Stability API key.") response = requests.get(url, headers={ "Authorization": f"Bearer {api_key}" }) if response.status_code != 200: raise Exception("Non-200 response: " + str(response.text)) # Do something with the payload... payload = response.json()
[- {
- "description": "Stability-AI Stable Diffusion v1.6",
- "id": "stable-diffusion-v1-6",
- "name": "Stable Diffusion v1.6",
- "type": "PICTURE"
}, - {
- "description": "Stability-AI Stable Diffusion XL v1.0",
- "id": "stable-diffusion-xl-1024-v1-0",
- "name": "Stable Diffusion XL v1.0",
- "type": "PICTURE"
}
]
Generate a new image from a text prompt
engine_id required | string Example: stable-diffusion-v1-6 |
Accept | string Default: application/json Enum: "application/json" "image/png" The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image. |
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
height | integer (DiffuseImageHeight) multiple of 64 >= 128 Default: 512 Height of the image to generate, in pixels, in an increment divible by 64. Engine-specific dimension validation:
|
width | integer (DiffuseImageWidth) multiple of 64 >= 128 Default: 512 Width of the image to generate, in pixels, in an increment divible by 64. Engine-specific dimension validation:
|
required | Array of objects (TextPrompts) non-empty An array of text prompts to use for generation. Given a text prompt with the text
|
cfg_scale | number (CfgScale) [ 0 .. 35 ] Default: 7 How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt) |
clip_guidance_preset | string (ClipGuidancePreset) Default: "NONE" Enum: "FAST_BLUE" "FAST_GREEN" "NONE" "SIMPLE" "SLOW" "SLOWER" "SLOWEST" |
sampler | string (Sampler) Enum: "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. |
samples | integer (Samples) [ 1 .. 10 ] Default: 1 Number of images to generate |
seed | integer (Seed) [ 0 .. 4294967295 ] Default: 0 Random noise seed (omit this option or use |
steps | integer (Steps) [ 10 .. 50 ] Default: 30 Number of diffusion steps to run. |
style_preset | string (StylePreset) Enum: "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. |
extras | object (Extras) 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. |
{- "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
}
]
}
{- "artifacts": [
- [
- {
- "base64": "...very long string...",
- "finishReason": "SUCCESS",
- "seed": 1050625087
}, - {
- "base64": "...very long string...",
- "finishReason": "CONTENT_FILTERED",
- "seed": 1229191277
}
]
]
}
Modify an image based on a text prompt
engine_id required | string Example: stable-diffusion-v1-6 |
Accept | string Default: application/json Enum: "application/json" "image/png" The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image. |
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
required | Array of objects (TextPrompts) non-empty An array of text prompts to use for generation. Due to how arrays are represented in Given a text prompt with the text
To add another prompt to that request simply provide the values under a new
|
init_image required | string <binary> (InitImage) Image used to initialize the diffusion process, in lieu of random noise. |
init_image_mode | string (InitImageMode) Default: "IMAGE_STRENGTH" Whether to use |
image_strength | number <float> (InitImageStrength) [ 0 .. 1 ] Default: 0.35 How much influence the |
cfg_scale | number (CfgScale) [ 0 .. 35 ] Default: 7 How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt) |
clip_guidance_preset | string (ClipGuidancePreset) Default: "NONE" Enum: "FAST_BLUE" "FAST_GREEN" "NONE" "SIMPLE" "SLOW" "SLOWER" "SLOWEST" |
sampler | string (Sampler) Enum: "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. |
samples | integer (Samples) [ 1 .. 10 ] Default: 1 Number of images to generate |
seed | integer (Seed) [ 0 .. 4294967295 ] Default: 0 Random noise seed (omit this option or use |
steps | integer (Steps) [ 10 .. 50 ] Default: 30 Number of diffusion steps to run. |
style_preset | string (StylePreset) Enum: "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. |
extras | object (Extras) 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. |
Request using 35% image_strength
{ "image_strength": 0.35, "init_image_mode": "IMAGE_STRENGTH", "init_image": "<image binary>", "text_prompts[0][text]": "A dog space commander", "text_prompts[0][weight]": 1, "cfg_scale": 7, "clip_guidance_preset": "FAST_BLUE", "sampler": "K_DPM_2_ANCESTRAL", "samples": 3, "steps": 30 }
{- "artifacts": [
- [
- {
- "base64": "...very long string...",
- "finishReason": "SUCCESS",
- "seed": 1050625087
}, - {
- "base64": "...very long string...",
- "finishReason": "CONTENT_FILTERED",
- "seed": 1229191277
}
]
]
}
Create a higher resolution version of an input image.
This operation outputs an image with a maximum pixel count of 4,194,304. This is equivalent to dimensions such as 2048x2048
and 4096x1024
.
By default, the input image will be upscaled by a factor of 2. For additional control over the output dimensions, a width
or height
parameter may be specified.
For upscaler engines that are ESRGAN-based, refer to the RealESRGANUpscaleRequestBody
body option below. For upscaler engines that are Stable Diffusion Latent Upscaler-based, refer to the LatentUpscalerUpscaleRequestBody
body option below.
For more details on the upscaler engines, refer to the documentation on the Platform site.
engine_id required | string Examples:
|
Accept | string Default: application/json Enum: "application/json" "image/png" The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image. |
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
image required | string <binary> (InputImage) |
width | integer (UpscaleImageWidth) >= 512 Desired width of the output image. Only one of |
height | integer (UpscaleImageHeight) >= 512 Desired height of the output image. Only one of |
Upscale input image by 2x using ESRGAN.
{ "image": "<image binary>" }
{- "artifacts": [
- [
- {
- "base64": "...very long string...",
- "finishReason": "SUCCESS",
- "seed": 1050625087
}, - {
- "base64": "...very long string...",
- "finishReason": "CONTENT_FILTERED",
- "seed": 1229191277
}
]
]
}
Selectively modify portions of an image using a mask
engine_id required | string Example: stable-diffusion-v1-6 |
Accept | string Default: application/json Enum: "application/json" "image/png" The format of the response. Leave blank for JSON, or set to 'image/png' for a PNG image. |
Organization | string Example: org-123456 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-ID | string Example: my-great-plugin Used to identify the source of requests, such as the client application or sub-organization. Optional, but recommended for organizational clarity. |
Stability-Client-Version | string Example: 1.2.1 Used to identify the version of the application or service making the requests. Optional, but recommended for organizational clarity. |
required | Array of objects (TextPrompts) non-empty An array of text prompts to use for generation. Due to how arrays are represented in Given a text prompt with the text
To add another prompt to that request simply provide the values under a new
|
init_image required | string <binary> (InitImage) Image used to initialize the diffusion process, in lieu of random noise. |
mask_source required | string (MaskSource) For any given pixel, the mask determines the strength of generation on a linear scale. This parameter determines where to source the mask from:
|
mask_image required | string <binary> (MaskImage) Optional grayscale mask that allows for influence over which pixels are eligible for diffusion and at what strength. Must be the same dimensions as the |
cfg_scale | number (CfgScale) [ 0 .. 35 ] Default: 7 How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt) |
clip_guidance_preset | string (ClipGuidancePreset) Default: "NONE" Enum: "FAST_BLUE" "FAST_GREEN" "NONE" "SIMPLE" "SLOW" "SLOWER" "SLOWEST" |
sampler | string (Sampler) Enum: "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. |
samples | integer (Samples) [ 1 .. 10 ] Default: 1 Number of images to generate |
seed | integer (Seed) [ 0 .. 4294967295 ] Default: 0 Random noise seed (omit this option or use |
steps | integer (Steps) [ 10 .. 50 ] Default: 30 Number of diffusion steps to run. |
style_preset | string (StylePreset) Enum: "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. |
extras | object (Extras) 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. |
{ "mask_source": "MASK_IMAGE_BLACK", "init_image": "<image binary>", "mask_image": "<image binary>", "text_prompts[0][text]": "A dog space commander", "text_prompts[0][weight]": 1, "cfg_scale": 7, "clip_guidance_preset": "FAST_BLUE", "sampler": "K_DPM_2_ANCESTRAL", "samples": 3, "steps": 30 }
{- "artifacts": [
- [
- {
- "base64": "...very long string...",
- "finishReason": "SUCCESS",
- "seed": 1050625087
}, - {
- "base64": "...very long string...",
- "finishReason": "CONTENT_FILTERED",
- "seed": 1229191277
}
]
]
}