Image Generation API
Generate AI images using multiple providers including OpenAI DALL-E, Stability AI, Google Gemini (Nano Banana), and Flux through a unified API.
Quick Start
🎨 Generate Images with AI
MCPHub's Image Generation API provides a simple interface to generate images from text prompts using multiple AI providers.
Production Endpoint
https://api.mcphub.com/api/v3/images/generateMultiple Providers
OpenAI, Google Gemini, Stability AI, Flux
Generate an Image
Python
import requests
# Get your API key from https://mcphub.com/settings/api-keys
api_key = "mcp_your_api_key_here"
# Generate an image
response = requests.post(
"https://api.mcphub.com/api/v3/images/generate",
headers={
"X-API-Key": api_key,
"Content-Type": "application/json"
},
json={
"prompt": "A serene mountain landscape at sunset",
"provider": "google", # google, openai, stability-ai, flux
"model": "gemini-2.5-flash-image-1024x1024",
"width": 1024,
"height": 1024
}
)
result = response.json()
print(f"Image URL: {result['image_url']}")
print(f"Credits used: {result['credits_used']}")TypeScript/JavaScript
// Get your API key from https://mcphub.com/settings/api-keys
const apiKey = 'mcp_your_api_key_here';
// Generate an image
const response = await fetch('https://api.mcphub.com/api/v3/images/generate', {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'A serene mountain landscape at sunset',
provider: 'google', // google, openai, stability-ai, flux
model: 'gemini-2.5-flash-image-1024x1024',
width: 1024,
height: 1024
})
});
const result = await response.json();
console.log(`Image URL: ${result.image_url}`);
console.log(`Credits used: ${result.credits_used}`);cURL
# Get your API key from https://mcphub.com/settings/api-keys
# Then use it to generate images
curl -X POST "https://api.mcphub.com/api/v3/images/generate" \
-H "X-API-Key: mcp_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene mountain landscape at sunset",
"provider": "google",
"model": "gemini-2.5-flash-image-1024x1024",
"width": 1024,
"height": 1024
}'Available Providers & Models
Google Gemini (Nano Banana)
gemini-2.5-flash-image-1024x1024gemini-2.5-flash-image-16:9gemini-2.5-flash-image-9:16
~34 credits per image
OpenAI DALL-E
dall-e-3dall-e-2
Varies by resolution & quality
📋 Get Full Model List
Retrieve all available image generation models and their pricing:
GET https://api.mcphub.com/api/v3/media-pricing/models?media_type=imageAPI Endpoints
/api/v3/images/generateGenerate an image from a text prompt
Request Body
prompt (required) - Text description of the imageprovider (optional) - AI provider: google, openai, stability-ai, fluxmodel (optional) - Specific model IDwidth (optional) - Image width in pixelsheight (optional) - Image height in pixels/api/v3/images/historyGet your image generation history
/api/v3/images/pricing/calculate-costCalculate cost before generating
Response Format
{
"success": true,
"image_id": "img_abc123",
"image_url": "https://...",
"provider": "google-genai",
"model": "gemini-2.5-flash-image-1024x1024",
"processing_time": 3.45,
"credits_used": 34.0,
"remaining_credits": 966.0,
"width": 1024,
"height": 1024,
"original_prompt": "A serene mountain landscape at sunset",
"status": "completed",
"created_at": "2025-11-12T10:30:00Z"
}Authentication
The Image Generation API uses API key authentication for simple and secure access:
Create API Key
Go to Settings → API Keys and create a new API key
Copy Your Key
Copy the generated API key (starts with mcp_)
Use in Requests
Include your API key in the X-API-Key header for all requests
🔐 Keep Your API Key Secure
Never share your API key publicly or commit it to version control. Treat it like a password.
Next Steps
📚 Related Docs
- • Video Generation API - Generate AI videos
- • API Reference - Complete API documentation
- • Pricing - Image generation costs
🚀 Get Started
- • Try in Dashboard - Generate images in the UI
- • Add Credits - Purchase credits
- • View History - Track your generations