Python SDK for interacting with stability.ai APIs
Project description
stability-sdk
Client implementations that interact with the Stability Generator API
Installation
Install the PyPI package via:
pip install stability-sdk
Getting an API key
You can manage API keys in your dreamstudio account here
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/activateto use the venv.- Set the
STABILITY_HOSTenvironment variable. This is by default set to the production endpointgrpc.stability.ai:443. - Set the
STABILITY_KEYenvironment variable.
Then to invoke:
python3 -m stability_sdk.client -W 512 -H 512 "A stunning house."
It will generate and put PNGs in your current directory.
SDK Usage
See usage demo notebooks in ./nbs
Command line usage
usage: python -m stability_sdk [-h] [--height HEIGHT] [--width WIDTH] [--start_schedule START_SCHEDULE]
[--end_schedule END_SCHEDULE] [--cfg_scale CFG_SCALE] [--sampler SAMPLER]
[--steps STEPS] [--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
[512] height of image
--width WIDTH, -W WIDTH
[512] 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
--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
Connecting to the API using languages other than Python
The src subdirectory contains pre-compiled gRPC stubs for the following languages:
If a language you would like to connect to the API with is not listed above, you can use the following protobuf definition to compile stubs for your language:
Community-contributed clients
- Typescript client: https://github.com/jakiestfu/stability-ts
- Guide to building for Ruby: https://github.com/kmcphillips/stability-sdk/blob/main/src/ruby/README.md
DreamStudio API TOS
Unless otherwise specified, usage of the dreamstudio API falls under the same usage terms as the dreamstudio web interface:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stability-sdk-0.3.2.tar.gz.
File metadata
- Download URL: stability-sdk-0.3.2.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48b95f23ce79cf57de3d6ee3b030cb79b6d2e452d1f18645ef60c9345f95aeb4
|
|
| MD5 |
cc77f399f6336b66ab8865457ed35b35
|
|
| BLAKE2b-256 |
6b0c1e4c81a63ead80455fc2272f2bb4d93a0f3eef615725a4f197f2bc252c09
|
File details
Details for the file stability_sdk-0.3.2-py3.8.egg.
File metadata
- Download URL: stability_sdk-0.3.2-py3.8.egg
- Upload date:
- Size: 101.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
844d5653c15294cfce9eced3e8f462216f0f557b2643e4b1ff89bebaf87ced81
|
|
| MD5 |
d3b70fc13d510b820f69dce0315f2b6c
|
|
| BLAKE2b-256 |
9c3d36a9187150a5eeac5b920d0bf1589e42de56441f1bf9cde4f4fc249aa818
|
File details
Details for the file stability_sdk-0.3.2-py3-none-any.whl.
File metadata
- Download URL: stability_sdk-0.3.2-py3-none-any.whl
- Upload date:
- Size: 48.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5313deb9b1411a822c7e5598b4c0de13f1c866384f66a16747a5a13dcd2490dd
|
|
| MD5 |
7c4a7fd09ce14f9ab34fdf7c59f23547
|
|
| BLAKE2b-256 |
21001a363b1df7316d22da644ae4e9586e33c1c7b94f6ca5e1104541077ac356
|