Docs/Guides/Image Generation

Image Generation

Learn how to generate images using AI models like FLUX, SDXL, and Stable Diffusion.

Available Models

ModelSpeedQualityBest For
fal-ai/flux/schnell~2sHighFast iteration, prototyping
fal-ai/flux/dev~12sHighestFinal production images
fal-ai/fast-sdxl~3sHighGeneral purpose
fal-ai/ideogram/v2~8sHighText in images

Basic Usage

Generate an image with a simple text prompt:

const result = await abstrakt.run('fal-ai/flux/schnell', {
  prompt: 'A serene Japanese garden with cherry blossoms',
  image_size: 'square_hd'
});

console.log(result.output.items[0].url);

Image Sizes

Choose from various aspect ratios and resolutions:

SizeDimensionsUse Case
square512×512Thumbnails, avatars
square_hd1024×1024Social media, general use
portrait_4_3768×1024Portrait photos
portrait_16_9576×1024Mobile wallpapers
landscape_4_31024×768Landscape photos
landscape_16_91024×576Video thumbnails, banners

Prompt Engineering

Better prompts lead to better results. Here are some tips:

Be Specific

Include details about subject, style, lighting, and composition.

❌ Vague

"A cat"

✓ Specific

"A fluffy orange tabby cat sleeping on a velvet cushion, soft window light, shallow depth of field"

Use Style Keywords

Add style modifiers to guide the aesthetic:

photorealisticdigital artoil paintinganime3d rendercinematicwatercolorminimalist

Describe Lighting

Lighting dramatically affects the mood:

golden hourdramatic lightingsoft diffused lightneon glowstudio lightingbacklitrim lighting

Advanced Options

Multiple Images

Generate multiple variations in a single request:

const result = await abstrakt.run('fal-ai/flux/schnell', {
  prompt: 'A futuristic cityscape',
  image_size: 'landscape_16_9',
  num_images: 4
});

// Access all generated images
result.output.items.forEach((item, i) => {
  console.log(`Image ${i + 1}: ${item.url}`);
});

Negative Prompts

Some models support negative prompts to exclude unwanted elements:

const result = await abstrakt.run('fal-ai/fast-sdxl', {
  prompt: 'A beautiful landscape photograph',
  negative_prompt: 'blurry, low quality, watermark, text',
  image_size: 'landscape_16_9'
});

Next Steps