Skip to content

Mage API · Image model

Stable Diffusion XL API

Photoreal-tuned SDXL

POST https://api.mage.space/v1/stable_diffusion_xl/generate

At a glance

The Stable Diffusion XL API runs Stable Diffusion XL through Mage at POST https://api.mage.space/v1/stable_diffusion_xl/generate. A request at the default settings costs 10 Gems (about $0.01), with no subscription. Stable Diffusion XL takes no @handle mentions.

  • ImageOutput
  • 1Variant
  • 10Gems per image, default
  • $0.01About, in USD

Overview

What the Stable Diffusion XL API does

Classic Stable Diffusion XL, tuned for photoreal output. Text-to-image or from one input image, at a budget price.

Stable Diffusion XL, tuned for photoreal output, with an optional input image.

It accepts image as inputs.

Quick start

Call the Stable Diffusion XL API

Set MAGE_API_KEY, submit to /stable_diffusion_xl/generate, and poll status_url until the request completes.

cURL
STATUS_URL=$(curl --request POST 'https://api.mage.space/v1/stable_diffusion_xl/generate' \
  --header "Authorization: Bearer $MAGE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "Editorial portrait in soft daylight, 35mm film look",
  "aspect_ratio": "4:5",
  "model_id": "6A35A7855770AE9820A3C931D4964C3817B6D9E3C6F9C4DABB5B3A94E5643B80"
}' | jq -r '.status_url')

# Repeat until status is "completed"; result.url is the file
curl "$STATUS_URL" --header "Authorization: Bearer $MAGE_API_KEY"
TypeScript
// npm install @mage-space/sdk
import Mage from '@mage-space/sdk';

const mage = new Mage(); // reads MAGE_API_KEY

const request = await mage.run('stable_diffusion_xl', {
  prompt: 'Editorial portrait in soft daylight, 35mm film look',
  aspect_ratio: '4:5',
  model_id: '6A35A7855770AE9820A3C931D4964C3817B6D9E3C6F9C4DABB5B3A94E5643B80',
});

console.log(request.result.url);
Python
# pip install mage-space
from mage_space import Mage

mage = Mage()  # reads MAGE_API_KEY

request = mage.run("stable_diffusion_xl", {
    "prompt": "Editorial portrait in soft daylight, 35mm film look",
    "aspect_ratio": "4:5",
    "model_id": "6A35A7855770AE9820A3C931D4964C3817B6D9E3C6F9C4DABB5B3A94E5643B80",
})

print(request["result"]["url"])

Models

Stable Diffusion XL model_id values

Send model_id to pick a variant. A request without one runs the default.

model_idNameDefault
6A35A7855770AE9820A3C931D4964C3817B6D9E3C6F9C4DABB5B3A94E5643B80Stable Diffusion XLYes

Options

Stable Diffusion XL parameters

Allowed values across all variants; a variant may offer fewer. The docs list the options per variant.

FieldValues
aspect_ratio21:9, 16:9, 3:2, 5:4, 1:1, 4:5, 2:3, 9:16, 9:21

Inputs

Media inputs Stable Diffusion XL accepts

Send each as an https URL, a data URL, or an upload of up to 100 MB.

FieldRole
imageThe reference image.

More image models

Other image generation APIs on Mage

  • Image · from 10 Gems

    Z-Image API

    The fastest image model on Mage

  • Image · from 20 Gems

    Anima API

    Purpose-built for anime

  • Image · from 35 Gems

    Chroma API

    Open-weights, built on Flux

  • Image · from 40 Gems

    Flux 2 API

    Long prompts and multi-reference edits

  • Image · from 9 Gems

    GPT Image 2 API

    Precise prompts and readable text

  • Image · from 90 Gems

    Grok Image API

    Grok Imagine, in two tiers

FAQ

Frequently asked questions

How much does the Stable Diffusion XL API cost?
A Stable Diffusion XL request at the default settings (Stable Diffusion XL) costs 10 Gems, about $0.01. Other resolutions, durations, and variants change the price; the response reports the exact charge. A generation that fails is refunded; one Mage's content policy blocks is not.
What is the Stable Diffusion XL API endpoint?
POST https://api.mage.space/v1/stable_diffusion_xl/generate with an Authorization: Bearer header carrying your Mage API key. The response includes a status_url to poll for the result.
Which Stable Diffusion XL models can I call?
6A35A7855770AE9820A3C931D4964C3817B6D9E3C6F9C4DABB5B3A94E5643B80. The default is Stable Diffusion XL.
Does Stable Diffusion XL support reference images or characters?
Stable Diffusion XL accepts image. Stable Diffusion XL takes no @handle mentions.
Can I use Stable Diffusion XL from Claude or ChatGPT?
Yes. Connect the Mage MCP server to Claude, ChatGPT, Claude Code, Grok, or Cursor and ask for Stable Diffusion XL by name. Your assistant reads its options with get_model and quotes the price before it generates.
How long are Stable Diffusion XL results kept?
Results and inputs are kept for 30 days. Download anything you want to keep to your own storage.

Start building with Mage

One account, one Gems balance, every model. Pay only for what you generate.