image generation

Stability AI logoStable Diffusion 3 Medium

State of the art open-source image generation model

Model details

View repository

Example usage

The model accepts a prompt which is some text describing the image you want to generate. The output images tend to get better as you add more descriptive words to the prompt.

The output JSON object contains a key called data which represents the generated image as a base64 string.

Input
1import requests
2import os
3import base64
4from PIL import Image
5from io import BytesIO
6
7# Replace the empty string with your model id below
8model_id = ""
9baseten_api_key = os.environ["BASETEN_API_KEY"]
10BASE64_PREAMBLE = "data:image/png;base64,"
11
12def b64_to_pil(b64_str):
13    return Image.open(BytesIO(base64.b64decode(b64_str.replace(BASE64_PREAMBLE, ""))))
14
15data = {
16  "prompt": "anime art of a steampunk inventor in their workshop, surrounded by gears, gadgets, and steam. He is holding a blue potion and a red potion, one in each hand",
17  "num_inference_steps": 30
18}
19
20# Call the model endpoint
21res = requests.post(
22  f"https://model-{model_id}.api.baseten.co/production/predict", 
23  headers={"Authorization": f"Api-Key {baseten_api_key}"},
24  json=data
25)
26
27# Get the response from the model
28res = res.json()
29
30# Save the base64 string to a PNG image
31img = b64_to_pil(res.get("data"))
32img.show()
33img.save("sd3.png")
JSON output
1{
2    "output": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAA..."
3}
Preview
Preview image

image generation models

See all
Fotographer AI
Image generation

ZenCtrl

Custom Server - H100
ByteDance logo
Image generation

SDXL Lightning

1.0 - Lightning - A100
Stability AI logo
Image generation

Stable Diffusion 3 Medium

3 - A100

Stability AI models

See all
Stability AI logo
Image generation

Stable Diffusion 3 Medium

3 - A100
Stability AI logo
Image generation

Stable Diffusion XL

XL 1.0 - A10G
Stability AI logo
Image generation

Stable Video Diffusion

Video 1.0 - A100

🔥 Trending models