Image Generation
Learn how to generate images using AI models like FLUX, SDXL, and Stable Diffusion.
Available Models
| Model | Speed | Quality | Best For |
|---|---|---|---|
| fal-ai/flux/schnell | ~2s | High | Fast iteration, prototyping |
| fal-ai/flux/dev | ~12s | Highest | Final production images |
| fal-ai/fast-sdxl | ~3s | High | General purpose |
| fal-ai/ideogram/v2 | ~8s | High | Text 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:
| Size | Dimensions | Use Case |
|---|---|---|
| square | 512×512 | Thumbnails, avatars |
| square_hd | 1024×1024 | Social media, general use |
| portrait_4_3 | 768×1024 | Portrait photos |
| portrait_16_9 | 576×1024 | Mobile wallpapers |
| landscape_4_3 | 1024×768 | Landscape photos |
| landscape_16_9 | 1024×576 | Video 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'
});