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 JWT token first
token_response = requests.post(
"https://api.mcphub.com/api/v3/user/token",
headers={"X-User-Id": "your-user-id"}
)
token = token_response.json()["data"]["accessToken"]
# Generate an image
response = requests.post(
"https://api.mcphub.com/api/v3/images/generate",
headers={
"Authorization": f"Bearer {token}",
"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 JWT token first
const tokenResponse = await fetch('https://api.mcphub.com/api/v3/user/token', {
method: 'POST',
headers: { 'X-User-Id': 'your-user-id' }
});
const { data: { accessToken } } = await tokenResponse.json();
// Generate an image
const response = await fetch('https://api.mcphub.com/api/v3/images/generate', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'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 JWT token first
curl -X POST "https://api.mcphub.com/api/v3/user/token" \
-H "X-User-Id: your-user-id"
# Generate image
curl -X POST "https://api.mcphub.com/api/v3/images/generate" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-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
POST
/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 pixelsGET
/api/v3/images/historyGet your image generation history
POST
/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 JWT token authentication:
1
Get User ID
Sign in and get your user ID from your account
2
Request JWT Token
POST to /api/v3/user/token with X-User-Id header
3
Use Token
Include token in Authorization header for all API requests
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