Overview
AI Image Generator creates high-quality images from text descriptions using advanced AI models. The API generates original artwork, photos, illustrations, and designs based on detailed text prompts with customizable styles, orientations, and resolutions.
How It Works
Write a prompt - Describe the image you want to create
Choose a style - Select from 30+ art styles and tools
Set orientation - Choose square, landscape, or portrait
API generates images - AI creates images matching your description
Download results - Retrieve your generated images
Use Cases
Content creation - Generate images for blogs, social media, marketing
Concept art - Visualize ideas before production
Stock photo replacement - Create custom images on-demand
Product mockups - Generate product visualizations
Creative projects - Artwork, illustrations, and designs
Best Practices
Writing Effective Prompts
Be specific and descriptive - The more detail you provide, the better the results.
✅ Good prompts:
“A serene mountain landscape at sunset with vibrant orange and purple colors, dramatic clouds, photorealistic style”
“Minimalist logo design of a flying bird in blue gradient, vector art style, clean lines”
“Cozy coffee shop interior with warm lighting, wooden furniture, plants, cinematic photography”
❌ Avoid:
Too vague: “A nice picture”
Too short: “Mountain”
Conflicting instructions: “Bright dark image”
Style Selection
Magic Hour offers 30+ art styles. Match the style to your use case:
Use Case Recommended Styles Marketing photos Photorealistic, Cinematic Illustrations Anime, Cartoon, Watercolor Logos & icons Vector, Minimalist Concept art Digital Art, Fantasy
Orientation Guidelines
Orientation Aspect Ratio Best For square1:1 Profile pictures, thumbnails, social posts landscape16:9 Banners, headers, desktop wallpapers portrait9:16 Stories, mobile wallpapers, posters
Code Examples
Basic Image Generation
from magic_hour import Client
import os
client = Client( token = os.getenv( "MAGIC_HOUR_API_KEY" ))
result = client.v1.ai_image_generator.generate(
image_count = 1 ,
orientation = "landscape" ,
style = {
"prompt" : "A serene mountain landscape at sunset with vibrant colors" ,
"tool" : "ai-photo-generator"
},
name = "Mountain Sunset" ,
wait_for_completion = True ,
download_outputs = True ,
download_directory = "./outputs/"
)
if result.status == "complete" :
print ( f "✅ Image complete!" )
print ( f "Downloaded to: { result.downloaded_paths } " )
print ( f "Credits charged: { result.credits_charged } " )
else :
print ( f "❌ Job failed with status: { result.status } " )
if hasattr (result, 'error_message' ):
print ( f "Error: { result.error_message } " )
Generate Multiple Images
result = client.v1.ai_image_generator.generate(
image_count = 4 , # Generate 4 variations
orientation = "square" ,
style = {
"prompt" : "Cute cat wearing sunglasses, digital art style" ,
"tool" : "ai-anime-generator"
},
name = "Cat Variations" ,
wait_for_completion = True ,
download_outputs = True ,
download_directory = "./outputs/"
)
if result.status == "complete" :
print ( f "✅ Image complete!" )
print ( f "Downloaded to: { result.downloaded_paths } " )
print ( f "Credits charged: { result.credits_charged } " )
else :
print ( f "❌ Job failed with status: { result.status } " )
if hasattr (result, 'error_message' ):
print ( f "Error: { result.error_message } " )
Portrait Orientation
result = client.v1.ai_image_generator.generate(
image_count = 1 ,
orientation = "portrait" ,
style = {
"prompt" : "Professional business woman in modern office" ,
"tool" : "ai-photo-generator"
},
name = "Business Portrait" ,
wait_for_completion = True ,
download_outputs = True ,
download_directory = "./outputs/"
)
if result.status == "complete" :
print ( f "✅ Images complete!" )
print ( f "Downloaded to: { result.downloaded_paths } " )
print ( f "Credits charged: { result.credits_charged } " )
else :
print ( f "❌ Job failed with status: { result.status } " )
if hasattr (result, 'error_message' ):
print ( f "Error: { result.error_message } " )
Pricing
Quality Credits per Image Standard 5 credits Pro quality 30 credits
API Reference
AI Image Generator API Reference View full API specification