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.
Our API also offers the ability to inpaint (the ability to modify a specific section of an image) via masking out a specific area of an image, and then generating new details based on a provided prompt. In the example below, this is accomplished by providing the gRPC API with a grayscale mask image, where black pixels represent the areas that will be replaced by the prompt, white pixels represent areas that are to be untouched by the inpainting process, and gray pixels result in partial replacement.
Try it out live by clicking the link below to open the notebook in Google Colab!Open In Colab

1. Install the Stability SDK package…

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

3. Establish our connection to the API…

4. Import the image we want to work with and a mask to inform which areas of the image we want affected by the diffusion process…

Imported image:

Imported Mask:

Feathered Mask:

5. Now we can generate a new image, including our mask to affect the specific areas laid out above…

Resulting image written to <seed>.png:

Final result.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.