# Image Generation Create stunning, high-quality images from text descriptions using NeuraAI's advanced image generation models. ## Basic Usage Generate images with a simple text prompt: ```python from openai import OpenAI client = OpenAI( base_url="https://api.neura-ai.app/v1" ) response = client.images.generate( model="dall-e-3", prompt="A futuristic city at sunset with flying cars and neon lights" ) print(response.data[0].url) ``` ## Prompt Enhancement Enable automatic prompt enhancement to get better results: ```python response = client.images.generate( model="dall-e-3", prompt="A cozy coffee shop interior", extra_body={"enhance": True} ) print(response.data[0].url) ``` When `enhance` is enabled, the API automatically improves your prompt by adding artistic details, style specifications, and quality modifiers. ## Image Size Some models support custom image dimensions: ```python response = client.images.generate( model="dall-e-3", prompt="A majestic mountain landscape", size="1024x1024" # Check model documentation for supported sizes ) ``` **Note:** Not all models support the `size` parameter. Refer to the [Models page](/models) to verify which models offer size customization. ## Supported Sizes Common size options (model-dependent): * `1024x1024` - Square format * `1792x1024` - Landscape * `1024x1792` - Portrait ## Advanced Examples ### Detailed Art Generation ```python response = client.images.generate( model="dall-e-3", prompt=""" An oil painting of a serene Japanese garden during cherry blossom season. Include a wooden bridge over a koi pond, stone lanterns, and Mount Fuji in the background. Style: traditional impressionism with soft brush strokes. """, extra_body={"enhance": True} ) ``` ### Product Visualization ```python response = client.images.generate( model="dall-e-3", prompt=""" A sleek, modern smartwatch on a marble surface with soft lighting. Professional product photography style, studio quality, high detail. """, size="1024x1024" ) ``` ### Character Design ```python response = client.images.generate( model="dall-e-3", prompt=""" A cyberpunk character portrait: female hacker with neon blue hair, augmented reality glasses, leather jacket with glowing circuit patterns. Dark background with holographic displays. Digital art style. """, extra_body={"enhance": True} ) ``` ### Architectural Concept ```python response = client.images.generate( model="dall-e-3", prompt=""" Futuristic eco-friendly skyscraper with vertical gardens, solar panels, and organic curved architecture. Surrounded by lush greenery. Architectural rendering style. """, size="1024x1792" ) ``` ## Working with Generated Images ### Downloading Images ```python import requests from PIL import Image from io import BytesIO response = client.images.generate( model="dall-e-3", prompt="A peaceful forest scene with sunlight filtering through trees" ) # Get the image URL image_url = response.data[0].url # Download and save img_response = requests.get(image_url) img = Image.open(BytesIO(img_response.content)) img.save("generated_image.png") ``` ### Multiple Variations Generate multiple images from the same prompt: ```python for i in range(3): response = client.images.generate( model="dall-e-3", prompt="A mystical wizard casting a spell" ) print(f"Variation {i+1}: {response.data[0].url}") ``` ## Prompt Writing Tips ### Be Specific Instead of: "A dog" Use: "A golden retriever puppy playing in autumn leaves, warm afternoon sunlight" ### Include Style Specify artistic style for better results: * "Watercolor painting of..." * "Photorealistic render of..." * "Minimalist line drawing of..." * "3D rendered..." ### Describe Composition Guide the layout and framing: * "Close-up portrait of..." * "Wide-angle landscape showing..." * "Bird's eye view of..." * "Centered composition with..." ### Set the Mood Add atmosphere and lighting: * "Dramatic lighting with strong shadows" * "Soft, dreamy atmosphere" * "Vibrant and energetic" * "Moody and mysterious" ## Best Practices * Use descriptive, detailed prompts for better results * Enable prompt enhancement for automatic improvements * Experiment with different artistic styles * Specify desired mood, lighting, and composition * Check model capabilities before using size parameter * Test multiple generations for the best output * Combine subjects, styles, and details thoughtfully ## Common Use Cases * Marketing materials and advertisements * Social media content * Concept art and design mockups * Book covers and illustrations * Product visualizations * Educational materials * Personal creative projects