Back to rankings

Stability-AI/stability-sdk

Jupyter Notebookplatform.stability.ai

SDK for interacting with stability.ai APIs (e.g. stable diffusion inference)

stable-diffusionai-artgenerative-artlatent-diffusionmultimodal
Star Growth
Stars
2.4k
Forks
339
Weekly Growth
Issues
37
1k2k
Aug 2022Nov 2023Mar 2025Jul 2026
README

stability-sdk

Open In Colab

Client implementations that interact with the Stability API.

Getting an API key

Follow the instructions on Platform to obtain an API key.

PyPI Package Installation

Install the PyPI package via:

pip install stability-sdk

Python Client

client.py is both a command line client and an API class that wraps the gRPC based API. To try the client:

  • Use Python venv: python3 -m venv pyenv
  • Set up in venv dependencies: pyenv/bin/pip3 install -e .
  • pyenv/bin/activate to use the venv.
  • Set the STABILITY_HOST environment variable. This is by default set to the production endpoint grpc.stability.ai:443.
  • Set the STABILITY_KEY environment variable.

Then to invoke:

python3 -m stability_sdk generate -W 1024 -H 1024 "A stunning house."

It will generate and put PNGs in your current directory.

To upscale: python3 -m stability_sdk upscale -i "/path/to/image.png"

Animation UI

Install with pip install stability-sdk[anim_ui]

Then run with python3 -m stability_sdk animate --gui

SDK Usage

Be sure to check out Platform for comprehensive documentation on how to interact with our API.

Command line usage

usage: python -m stability_sdk generate [-h] [--height HEIGHT] [--width WIDTH] 
                [--start_schedule START_SCHEDULE] [--end_schedule END_SCHEDULE] 
                [--cfg_scale CFG_SCALE] [--sampler SAMPLER] [--steps STEPS] 
                [--style_preset STYLE_PRESET] [--seed SEED] [--prefix PREFIX] [--engine ENGINE]
                [--num_samples NUM_SAMPLES] [--artifact_types ARTIFACT_TYPES]
                [--no-store] [--show] [--init_image INIT_IMAGE] [--mask_image MASK_IMAGE]
                [prompt ...]

positional arguments:
  prompt

options:
  -h, --help            show this help message and exit
  --height HEIGHT, -H HEIGHT
                        [1024] height of image
  --width WIDTH, -W WIDTH
                        [1024] width of image
  --start_schedule START_SCHEDULE
                        [0.5] start schedule for init image (must be greater than 0; 1 is full strength
                        text prompt, no trace of image)
  --end_schedule END_SCHEDULE
                        [0.01] end schedule for init image
  --cfg_scale CFG_SCALE, -C CFG_SCALE
                        [7.0] CFG scale factor
  --sampler SAMPLER, -A SAMPLER
                        [auto-select] (ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2,
                        k_dpm_2_ancestral, k_lms, k_dpmpp_2m, k_dpmpp_2s_ancestral)
  --steps STEPS, -s STEPS
                        [auto] number of steps
  --style_preset STYLE_PRESET
                        [none] (3d-model, analog-film, anime, cinematic, comic-book, digital-art, enhance, 
                        fantasy-art, isometric, line-art, low-poly, modeling-compound, neon-punk, origami, 
                        photographic, pixel-art, tile-texture)
  --seed SEED, -S SEED  random seed to use
  --prefix PREFIX, -p PREFIX
                        output prefixes for artifacts
  --artifact_types ARTIFACT_TYPES, -t ARTIFACT_TYPES
                        filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)
  --no-store            do not write out artifacts
  --num_samples NUM_SAMPLES, -n NUM_SAMPLES
                        number of samples to generate
  --show                open artifacts using PIL
  --engine ENGINE, -e ENGINE
                        engine to use for inference
  --init_image INIT_IMAGE, -i INIT_IMAGE
                        Init image
  --mask_image MASK_IMAGE, -m MASK_IMAGE
                        Mask image

For upscale:

usage: client.py upscale
       [-h]
       --init_image INIT_IMAGE
       [--height HEIGHT] [--width WIDTH] [--prefix PREFIX] [--artifact_types ARTIFACT_TYPES]
       [--no-store] [--show] [--engine ENGINE]

positional arguments:
  prompt (ignored in esrgan engines)

options:
  -h, --help            show this help message and exit
  --init_image INIT_IMAGE, -i INIT_IMAGE
                        Init image
  --height HEIGHT, -H HEIGHT
                        height of upscaled image in pixels
  --width WIDTH, -W WIDTH
                        width of upscaled image in pixels
  --steps STEPS, -s STEPS
                        [auto] number of steps (ignored in esrgan engines)
  --seed SEED, -S SEED  random seed to use (ignored in esrgan engines)
  --cfg_scale CFG_SCALE, -C CFG_SCALE
                        [7.0] CFG scale factor (ignored in esrgan engines)
  --prefix PREFIX, -p PREFIX
                        output prefixes for artifacts
  --artifact_types ARTIFACT_TYPES, -t ARTIFACT_TYPES
                        filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)
  --no-store            do not write out artifacts
  --show                open artifacts using PIL
  --engine ENGINE, -e ENGINE
                        engine to use for upscale
  

Connecting to the API using languages other than Python

If a language you would like to connect to the API with is not currently documented on Platform you can use the following protobuf definition to compile stubs for your language:

Community-contributed clients

Stability API TOS

Usage of the Stability API falls under the STABILITY AI API Terms of Service.

Related repositories
AUTOMATIC1111/stable-diffusion-webui

Stable Diffusion web UI

PythonPyPIGNU Affero General Public License v3.0deep-learningdiffusion
164.3k30.4k
Comfy-Org/ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.

PythonPyPIGNU General Public License v3.0stable-diffusionpytorch
comfy.org
121.6k14.3k
comfyanonymous/ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.

PythonPyPIGNU General Public License v3.0stable-diffusionpytorch
comfy.org
70.2k7.6k
mudler/LocalAI

LocalAI is the open-source AI engine. Run any model - LLMs, vision, voice, image, video - on any hardware. No GPU required.

GoGo ModulesMIT Licensellamaai
localai.io
47.7k4.3k
calesthio/OpenMontage

World's first open-source, agentic video production system. 12 pipelines, 52 tools, 500+ agent skills. Turn your AI coding assistant into a full video production studio.

PythonPyPIGNU Affero General Public License v3.0agentagentic-ai
openmontage.video
40.6k4.8k
huggingface/diffusers

🤗 Diffusers: State-of-the-art diffusion models for image, video, and audio generation in PyTorch.

PythonPyPIApache License 2.0deep-learningdiffusion
huggingface.co/docs/diffusers
34.1k7.2k
invoke-ai/InvokeAI

Invoke is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, and serves as the foundation for multiple commercial products.

PythonPyPIApache License 2.0ai-artartificial-intelligence
invoke-ai.github.io/InvokeAI/
27.6k2.9k
Sanster/IOPaint

Image inpainting tool powered by SOTA AI Model. Remove any unwanted object, defect, people from your pictures or erase and replace(powered by stable diffusion) any thing on your pictures.

PythonPyPIApache License 2.0inpaintingpytorch
iopaint.com
23.3k2.5k
camenduru/stable-diffusion-webui-colab

stable diffusion webui colab

Jupyter NotebookThe Unlicensestable-diffusionstable-diffusion-web-ui
15.9k2.6k
divamgupta/diffusionbee-stable-diffusion-ui

Diffusion Bee is the easiest way to run Stable Diffusion locally on your M1 Mac. Comes with a one-click installer. No dependencies or technical knowledge needed.

JavaScriptnpmGNU Affero General Public License v3.0electron-appmacos
diffusionbee.com
13.6k725
hua1995116/awesome-ai-painting

AI绘画资料合集(包含国内外可使用平台、使用教程、参数教程、部署教程、业界新闻等等) Stable diffusion、AnimateDiff、Stable Cascade 、Stable SDXL Turbo

disco-diffusionstable-diffusion
goenhance.ai
11.8k959
Baiyuetribe/paper2gui

Convert AI papers to GUI,Make it easy and convenient for everyone to use artificial intelligence technology。让每个人都简单方便的使用前沿人工智能技术

Jupyter NotebookMIT Licensedainhuoshan-tts
xiaobaituai.com
10.7k878