Image Generation

AI

Generate images from text prompts using AI image generation models.

DALL-E 3

Best quality & prompts

Multiple Sizes

Square, portrait, landscape

HD Quality

Standard or high detail

Image Editing

Edit with masks

Overview

Generate images from text descriptions using state-of-the-art AI models. Create artwork, product images, illustrations, and more.

Generate Images

Create an image from a text prompt:

import { platform } from '@/lib/platform'

const result = await platform.ai.generateImage({
  model: 'openai/dall-e-3',
  prompt: 'A serene Japanese garden with cherry blossoms, koi pond, and a wooden bridge, digital art style',
  size: '1024x1024',
})

console.log(result.url) // URL to generated image
// Or result.base64 if you requested base64 format

Supported Models

Available image generation models:

PropertyTypeDescription
openai/dall-e-31024x1024, 1024x1792, 1792x1024Highest quality, best prompt following
openai/dall-e-2256x256, 512x512, 1024x1024Faster, more cost-effective
stabilityai/stable-diffusion-xl1024x1024, variousOpen-source, highly customizable

Options

Customize image generation:

const result = await platform.ai.generateImage({
  model: 'openai/dall-e-3',
  prompt: 'A futuristic city skyline at sunset',

  // Size options
  size: '1792x1024', // Landscape

  // Quality (openai/dall-e-3)
  quality: 'hd', // 'standard' or 'hd'

  // Style (openai/dall-e-3)
  style: 'vivid', // 'vivid' or 'natural'

  // Response format
  responseFormat: 'url', // 'url' or 'base64'

  // Multiple images (openai/dall-e-2 only)
  n: 1, // Number of images (1-4)

  // User tracking
  userId: user.id,
})

Multiple Images

Generate multiple variations (DALL-E 2):

// DALL-E 2 supports multiple images
const result = await platform.ai.generateImage({
  model: 'openai/dall-e-2',
  prompt: 'A cute robot mascot, cartoon style',
  size: '512x512',
  n: 4, // Generate 4 variations
})

result.images.forEach((img, i) => {
  console.log(`Image ${i + 1}: ${img.url}`)
})

DALL-E 3

DALL-E 3 only generates one image at a time but produces higher quality results with better prompt understanding.

Image Editing

Edit existing images (DALL-E 2):

// Edit an image with a mask
const result = await platform.ai.editImage({
  model: 'openai/dall-e-2',
  image: imageFile, // Original image (PNG, < 4MB)
  mask: maskFile,   // Mask indicating area to edit (PNG with transparency)
  prompt: 'A red sports car',
  size: '1024x1024',
})

Image Variations

Generate variations of an existing image:

const result = await platform.ai.createImageVariation({
  model: 'openai/dall-e-2',
  image: imageFile, // Source image (PNG, < 4MB)
  n: 3,             // Number of variations
  size: '1024x1024',
})

Prompt Tips

Write effective prompts for better results:

Be specific

Include style, lighting, composition

Specify medium

digital art, oil painting, 3D render

Describe mood

peaceful, dramatic, whimsical

Artist styles

"in the style of Studio Ghibli"

Technical terms

bokeh, wide angle, macro shot

Good prompt example
const prompt = `
A cozy coffee shop interior with warm lighting,
exposed brick walls, wooden furniture,
plants on shelves, steam rising from cups,
soft morning light through large windows,
digital illustration, warm color palette,
Studio Ghibli inspired, highly detailed
`

Content Policy

All generated images must comply with content policies. The API will reject prompts that:

  • Request violent or harmful content
  • Generate adult or explicit material
  • Create deepfakes of real people
  • Produce misleading content

Moderation

Prompts are automatically moderated. Repeated policy violations may result in account restrictions.