S

Stable Diffusion API

Image Generation

by Stability AI

Stability AI's official API for Stable Diffusion models including SD 3.5, Stable Image Core, and Stable Image Ultra. Open-source models also available for self-hosting.

Official APIDocumentationFree: Free for <$1M revenue

Registration & API Key Steps

1

Create Stability AI Account

Visit platform.stability.ai and sign up for a free developer account.

Open link
2

Get Free Credits

New accounts receive 25 free credits (1 credit = $0.01). This allows for about 3-4 free image generations.

3

Generate API Key

Go to your account settings and generate an API key for programmatic access.

Open link
4

Purchase Additional Credits

Buy credits as needed. Credits never expire. 1 credit = $0.01.

Pricing

TierPriceFeatures
Stable Image Core$0.03 / image (3 credits)Fast generation, Affordable, Good quality for most use cases
Stable Diffusion 3.5 Medium$0.035 / image (3.5 credits)SD 3.5 architecture, Medium quality, Balance of speed and quality
Stable Diffusion 3.5 Large$0.065 / image (6.5 credits)Best SD 3.5 quality, High detail, Advanced prompt understanding
Stable Image Ultra$0.08 / image (8 credits)State-of-the-art quality, Based on SD 3.5, Best for premium use cases
Community License (Free)Free for <$1M revenueSelf-hosted deployment, Full model weights, Non-commercial or small business use

Application Tips

Free for Small Businesses

Organizations with annual revenue under $1M can use models commercially for free under the Community License.

Self-Host for Cost Savings

Stable Diffusion models are open-source. For high volume, self-hosting on your own GPU hardware can be significantly cheaper than API calls.

Credits Never Expire

Unlike OpenAI, Stability AI credits do not expire, so you can buy in bulk without worrying about expiration.

China Access Solutions

Self-Hosting

Download open-source model weights from Hugging Face and deploy locally or on Chinese cloud providers.

API Proxy

Use overseas server as relay to access Stability AI API from China.

Code Example

JavaScript / TypeScript
import fetch from 'node-fetch';
import fs from 'fs';

async function generateImage() {
  const response = await fetch(
    'https://api.stability.ai/v2beta/stable-image/generate/sd3',
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.STABILITY_API_KEY}`,
        'Accept': 'image/*',
      },
      body: (() => {
        const formData = new FormData();
        formData.append('prompt', 'A beautiful sunset over mountains, photorealistic');
        formData.append('model', 'sd3.5-large');
        formData.append('output_format', 'png');
        return formData;
      })(),
    }
  );

  if (response.ok) {
    const buffer = await response.arrayBuffer();
    fs.writeFileSync('output.png', Buffer.from(buffer));
    console.log('Image saved as output.png');
  }
}

generateImage();

Rate Limits

TierLimits
Default150 requests/10 seconds

Recommended Use Cases

Batch image generationCustom model fine-tuningProduct photographyGame asset creationSelf-hosted solutions
Last Updated: 2025-02

Related API Guides