Stable Diffusion API
Image Generationby 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.
Registration & API Key Steps
Create Stability AI Account
Visit platform.stability.ai and sign up for a free developer account.
Open linkGet Free Credits
New accounts receive 25 free credits (1 credit = $0.01). This allows for about 3-4 free image generations.
Generate API Key
Go to your account settings and generate an API key for programmatic access.
Open linkPurchase Additional Credits
Buy credits as needed. Credits never expire. 1 credit = $0.01.
Pricing
| Tier | Price | Features |
|---|---|---|
| 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 revenue | Self-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
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
| Tier | Limits |
|---|---|
| Default | 150 requests/10 seconds |
Recommended Use Cases
Related API Guides
DALL-E 3
OpenAI
OpenAI's most advanced image generation model, capable of creating highly detailed and accurate images from text descriptions with excellent prompt following.
Midjourney
Midjourney Inc.
Industry-leading AI image generation known for stunning artistic quality. No official public API yet; access via Discord bot or third-party API services.
Imagen 3
Google's state-of-the-art image generation model, available through the Gemini API and Vertex AI. Excels in photorealistic images with SynthID watermarking.
Ideogram
Ideogram AI
AI image generation specializing in accurate text rendering within images. Excellent for logos, posters, and designs requiring readable text.