Skip to main content
The gRPC API is in legacy maintenance mode and won’t receive new features. For new projects, use the REST v2beta API.
One of the core foundations of the API is the ability to generate images via prompting. With multi-prompting, you can mix concepts together by assigning each prompt a specific weight. Check out the examples below to learn how to execute multi-prompting calls via our API. With the ability to assign weights to individual prompts, developers can now negatively prompt Stable Diffusion, a popular strategy for generating more creative images by informing the model to avoid certain concepts. Try it out live by clicking the link below to open the notebook in Google Colab! Open In Colab

Python Example

1. Install the Stability SDK package…

2. Import our dependencies and set up our environment variables and API Key…

3. Connect to the Stability API…

4. Set up basic text-to-image parameters, save image on generation, and warning for if the safety filter is tripped…

Resulting image written to <seed>.png:

5. Set up multiprompt text-to-image parameters based on previous basic prompt for comparison…

Resulting image written to <seed>.png:

Note: This is not representative of all of the parameters available for image generation. Please check out our protobuf reference for a complete list of parameters available for image generation.