Back to Eliza

Image Generation

packages/cloud-frontend/content/image-generation.mdx

2.0.16.3 KB
Original Source

import { Callout, Tabs, Cards } from "@/docs/components";

Image Generation

Generate high-quality images from text prompts using state-of-the-art AI models.

<div className="status-badge status-stable">Stable</div>

Overview

elizaOS Cloud provides image generation through the configured image provider catalog. See the Images API reference or API Explorer for current models and defaults.

Quick Start

Dashboard

Navigate to Dashboard → Images for the visual interface.

API

<Tabs items={['cURL', 'JavaScript', 'Python']}> <Tabs.Tab>

bash
curl -X POST "https://elizacloud.ai/api/v1/generate-image" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at sunset, cyberpunk style",
    "model": "google/gemini-2.5-flash-image",
    "aspectRatio": "16:9",
    "numImages": 1
  }'

</Tabs.Tab> <Tabs.Tab>

javascript
const response = await fetch('https://elizacloud.ai/api/v1/generate-image', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    prompt: 'A futuristic cityscape at sunset, cyberpunk style',
    model: 'google/gemini-2.5-flash-image',
    aspectRatio: '16:9',
    numImages: 1,
  }),
});

const result = await response.json();
console.log(result.images[0].url);

</Tabs.Tab> <Tabs.Tab>

python
import requests

response = requests.post(
    'https://elizacloud.ai/api/v1/generate-image',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'prompt': 'A futuristic cityscape at sunset, cyberpunk style',
        'model': 'google/gemini-2.5-flash-image',
        'aspectRatio': '16:9',
        'numImages': 1,
    },
)

result = response.json()
print(result['images'][0]['url'])

</Tabs.Tab> </Tabs>

Response

json
{
  "images": [
    {
      "url": "https://your-storage.vercel-storage.com/images/abc123.webp",
      "text": "Optional model response text",
      "mimeType": "image/webp",
      "fileSize": 102400
    }
  ],
  "numImages": 1
}

Available Models

Model availability and defaults are documented in the canonical Images API reference. Use that page or the API Explorer for the current model catalog and pricing-sensitive defaults.

Request Parameters

ParameterTypeRequiredDescription
promptstringText description of the image
modelstringModel to use (default: google/gemini-2.5-flash-image)
aspectRatiostringOutput aspect ratio (default: 1:1)
numImagesintegerNumber of images (1-4, default: 1)
stylePresetstringStyle preset to apply
sourceImagestringBase64 data URL for image-to-image

Available Aspect Ratios

Aspect RatioDescription
1:1Square (default)
16:9Wide landscape
9:16Tall portrait
4:3Standard landscape
3:4Standard portrait
21:9Ultra-wide cinematic
9:21Ultra-tall vertical

Style Presets

PresetDescription
noneNo style modification (default)
photographicRealistic lighting and details
digital-artVibrant colors, modern aesthetics
comic-bookBold lines, dramatic shading
fantasy-artMagical and ethereal elements
analog-filmFilm grain and vintage tones
neon-punkCyberpunk style with neon colors
cinematicDramatic lighting and composition

Image-to-Image Generation

Transform existing images by providing a sourceImage parameter:

javascript
const response = await fetch("https://elizacloud.ai/api/v1/generate-image", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "Transform this into a watercolor painting",
    sourceImage: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
  }),
});

Prompt Engineering

Basic Structure

[Subject] [Style] [Details] [Lighting] [Mood]

Example Prompts

Photorealistic:

json
{
  "prompt": "Professional headshot of a business executive, studio lighting, neutral background, sharp focus",
  "stylePreset": "photographic"
}

Artistic:

json
{
  "prompt": "Enchanted forest with glowing mushrooms, magical atmosphere, soft moonlight filtering through trees",
  "stylePreset": "fantasy-art"
}

Product:

json
{
  "prompt": "Modern smartphone on white background, professional product photography, soft shadows",
  "aspectRatio": "4:3"
}

Best Practices

  • Be specific: Include details about style, lighting, composition
  • Use style presets: For consistent results across generations
  • Iterate: Generate multiple images and refine your prompt
  • Aspect ratio matters: Choose based on your use case

Error Handling

CodeErrorSolution
400Invalid promptEnsure prompt is non-empty
400Invalid modelUse a supported model
402Insufficient creditsAdd credits to your account
429Rate limitedWait and retry
500Generation failedRetry or try a different model

Next Steps

<Cards> <Cards.Card title="API Reference" href="/docs/api/images"> Complete API documentation </Cards.Card> <Cards.Card title="Gallery" href="/docs/gallery"> View and manage your images </Cards.Card> <Cards.Card title="Video Generation" href="/docs/video-generation"> Generate videos from text </Cards.Card> </Cards>