AI Image Generation API
Call Flux, SDXL and 10,000+ models on one REST API. Self-hosted image models cost $0.0047 per image, and the $149 plan makes them unlimited.
- From $0.0047 per image
- Unlimited open-source images for $149/mo
- Plans from $21/mo
One API for text to image, image to image and inpainting
The ModelsLab AI image generation API turns a prompt or an input image into new images. Text to image, image to image and inpainting use the same REST API and the same API key. You pick the model with one parameter, model_id.
One subscription and one API key cover image, video, speech and LLM APIs. API calls need a paid plan, from $21 a month.
Trusted by
API Requests Processed
Registered Users
Discord Community Members
Available AI APIs
GPUs in Our Own Datacenter
Text to image API
Send a prompt and a model_id to POST /api/v7/images/text-to-image. The response contains the URLs of the generated images.
prompt: the text that describes the image.model_id: the model to run, for examplefluxorsdxl.samples: up to 4 images per request.webhook: a URL. We post the result to it when the images are ready.
Optional fields such as negative_prompt, width and height control what the model leaves out and the image size.
Image to image, inpainting and editing
To change an existing image, send its URL in init_image with a prompt to POST /api/v7/images/image-to-image. Use it to restyle a photo, change a scene or make variations.
Inpainting edits only the masked part of an image and keeps the rest. Both workflows use the same API key and the same models as text to image. Self-hosted models cost the same $0.0047 per image.
Models you can call
Flux, SDXL, Juggernaut XL, Realistic Vision and 10,000+ community checkpoints and LoRAs run on our own GPUs. To change the model, change model_id. The request shape stays the same.
For model-specific parameters and examples, read the Flux API and Stable Diffusion API guides.
Quick start
Generate images with the v7 text to image endpoint. Replace YOUR_API_KEY with the key from your dashboard.
Text to image with Python
Python1import requests23url = "https://modelslab.com/api/v7/images/text-to-image"4payload = {5 "key": "YOUR_API_KEY",6 "model_id": "flux",7 "prompt": "professional product photo of a sneaker, studio lighting, white background",8 "negative_prompt": "blurry, distorted, low quality",9 "width": 1024,10 "height": 1024,11 "samples": 412}1314response = requests.post(url, json=payload)15data = response.json()1617# data["output"] is a list of image URLs18for i, image_url in enumerate(data["output"]):19 print(f"Image {i + 1}: {image_url}")
Text to image with JavaScript (Node.js)
JavaScript1const response = await fetch('https://modelslab.com/api/v7/images/text-to-image', {2 method: 'POST',3 headers: { 'Content-Type': 'application/json' },4 body: JSON.stringify({5 key: 'YOUR_API_KEY',6 model_id: 'flux',7 prompt: 'professional product photo of a sneaker, studio lighting',8 width: 1024,9 height: 1024,10 samples: 411 })12});1314const data = await response.json();15// data.output is an array of image URLs16data.output.forEach((url, i) => console.log(`Image ${i + 1}: ${url}`));
Text to image with cURL and a webhook
curl1curl -X POST 'https://modelslab.com/api/v7/images/text-to-image' \2 -H 'Content-Type: application/json' \3 -d '{4 "key": "YOUR_API_KEY",5 "model_id": "sdxl",6 "prompt": "a cozy coffee shop interior, warm lighting, rain on windows",7 "width": 1024,8 "height": 1024,9 "samples": 1,10 "webhook": "https://example.com/modelslab-webhook"11 }'
Image generation API pricing
Each plan is a dollar allowance, not a call count. Self-hosted image models cost $0.0047 per image on Basic and Standard and have no per-image charge on the $149 plan. Partner models use the plan allowance first on Basic and Standard, then the wallet, and bill from the wallet on the $149 plan. Compare costs by volume on the cheapest image generation API breakdown, or see what the Unlimited AI API plan covers.
| Plan | Price per month | Self-hosted image models | Parallel generations |
|---|---|---|---|
| Basic | $21 | $0.0047 per image from the plan allowance | 5 |
| Standard | $47 | $0.0047 per image from the plan allowance | 10 |
| Open Source Unlimited | $149 | No per-image charge (about $0.0015 per image at 100,000 images a month) | 15 |
Yearly plans: Basic $210, Standard $451, Open Source Unlimited $1,500.
Plans from $21 a month
Basic is $21/month and Standard $47/month; self-hosted image models cost $0.0047 per image from that allowance. Open Source Unlimited is $149/month with no per-image charge on self-hosted models. Every plan covers Flux, SDXL and 10,000+ community models. Cancel anytime.
Open Source Unlimited
Mission-Critical
🛡️ 100% refund policy · cancel anytime
Standard
Production
🛡️ 100% refund policy · cancel anytime
Basic
Prototype
🛡️ 100% refund policy · cancel anytime
Get your AI image generation API key
Plans start at $21 a month. The same key works for image, video, speech and LLM APIs.
Get API keyRelated Image APIs
- Cheapest image generation API
Cost per image at 3,250 to 500,000 images a month.
- Flux API
Flux models over REST, self-hosted.
- Stable Diffusion API
SDXL, SD 1.5 and community checkpoints.
- Best AI image generation APIs in 2026
Providers compared on price, speed and models.
- Cheapest AI API
Image, video and speech prices side by side.
- Unlimited AI API
Every self-hosted open-source model for $149/mo.
Get Expert Support in Seconds
We're Here to Help.
Want to know more? You can email us anytime at support@modelslab.com
Explore Our Other Solutions
Unlock your creative potential and scale your business with ModelsLab's comprehensive suite of AI-powered solutions.
AI Audio Generation
Text-to-speech, voice cloning, music generation, and audio processing APIs.
AI Video Generation & Tools
Create, edit, and enhance videos with AI-powered generation and transformation tools.
Engage Seamlessly with LLM
Access powerful language models for chatbots, content generation, and AI assistants.
Create Stunning 3D Models
Transform images and text into 3D models with advanced AI-powered generation.
Explore Plugins for Pro
Our plugins are designed to work with the most popular content creation software.
Build Apps with ModelsLabML API
Use our API to build apps, generate AI art, create videos, and produce audio with ease.