Skip to main content

Quick Start

Get started with Stability AI in under 2 minutes:
from portkey_ai import Portkey

# 1. Install: pip install portkey-ai
# 2. Add @stability-ai provider in model catalog
# 3. Use it:

portkey = Portkey(api_key="PORTKEY_API_KEY")

image = portkey.images.generate(
    model="@stability-ai/stable-diffusion-v1-6",
    prompt="A serene landscape with mountains",
    size="1024x1024"
)

print(image.data[0].url)
Tip: You can also set provider="@stability-ai" in Portkey() and use just model="stable-diffusion-v1-6" in the request.

Add Provider in Model Catalog

Before making requests, add Stability AI to your Model Catalog:
  1. Go to Model Catalog → Add Provider
  2. Select Stability AI
  3. Enter your Stability AI API key
  4. Name your provider (e.g., stability-ai)

Complete Setup Guide

See all setup options and detailed configuration instructions

Image Generation

Generate high-quality images with Stable Diffusion:
from portkey_ai import Portkey

portkey = Portkey(api_key="PORTKEY_API_KEY", provider="@stability-ai")

image = portkey.images.generate(
  model="stable-diffusion-v1-6",
    prompt="A serene landscape with mountains and a lake at sunset",
  size="1024x1024"
)

print(image.data[0].url)
Portkey uses the OpenAI image generation signature for Stability AI, allowing you to easily switch between providers.

Supported Models

Stability AI offers powerful image generation models:
ModelDescription
stable-diffusion-v1-6High-quality general-purpose image generation
stable-diffusion-xl-1024-v1-0XL model for larger, more detailed images
Check Stability AI’s documentation for the complete model list.

Next Steps

For complete SDK documentation:

SDK Reference

Complete Portkey SDK documentation