Image Generation

View as Markdown

Create stunning, high-quality images from text descriptions using NeuraAI’s advanced image generation models.

Basic Usage

Generate images with a simple text prompt:

1from openai import OpenAI
2
3client = OpenAI(
4 base_url="https://api.neura-ai.app/v1"
5)
6
7response = client.images.generate(
8 model="dall-e-3",
9 prompt="A futuristic city at sunset with flying cars and neon lights"
10)
11
12print(response.data[0].url)

Prompt Enhancement

Enable automatic prompt enhancement to get better results:

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="A cozy coffee shop interior",
4 extra_body={"enhance": True}
5)
6
7print(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:

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="A majestic mountain landscape",
4 size="1024x1024" # Check model documentation for supported sizes
5)

Note: Not all models support the size parameter. Refer to the Models page 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

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="""
4 An oil painting of a serene Japanese garden during cherry blossom season.
5 Include a wooden bridge over a koi pond, stone lanterns, and Mount Fuji
6 in the background. Style: traditional impressionism with soft brush strokes.
7 """,
8 extra_body={"enhance": True}
9)

Product Visualization

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="""
4 A sleek, modern smartwatch on a marble surface with soft lighting.
5 Professional product photography style, studio quality, high detail.
6 """,
7 size="1024x1024"
8)

Character Design

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="""
4 A cyberpunk character portrait: female hacker with neon blue hair,
5 augmented reality glasses, leather jacket with glowing circuit patterns.
6 Dark background with holographic displays. Digital art style.
7 """,
8 extra_body={"enhance": True}
9)

Architectural Concept

1response = client.images.generate(
2 model="dall-e-3",
3 prompt="""
4 Futuristic eco-friendly skyscraper with vertical gardens, solar panels,
5 and organic curved architecture. Surrounded by lush greenery.
6 Architectural rendering style.
7 """,
8 size="1024x1792"
9)

Working with Generated Images

Downloading Images

1import requests
2from PIL import Image
3from io import BytesIO
4
5response = client.images.generate(
6 model="dall-e-3",
7 prompt="A peaceful forest scene with sunlight filtering through trees"
8)
9
10# Get the image URL
11image_url = response.data[0].url
12
13# Download and save
14img_response = requests.get(image_url)
15img = Image.open(BytesIO(img_response.content))
16img.save("generated_image.png")

Multiple Variations

Generate multiple images from the same prompt:

1for i in range(3):
2 response = client.images.generate(
3 model="dall-e-3",
4 prompt="A mystical wizard casting a spell"
5 )
6 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