fal.ai Image Generation & Editing Skill
Professional AI-powered image workflows using fal.ai's state-of-the-art models including FLUX, Recraft V3, Imagen4, and more.
Three Modes of Operation
1. Text-to-Image (fal-text-to-image)
Generate images from scratch using text prompts
2. Image Remix (fal-image-remix)
Transform existing images while preserving composition
3. Image Edit (fal-image-edit)
Targeted inpainting and masked editing
When to Use This Skill
Trigger when user:
- - Requests image generation from text descriptions
- Wants to transform/remix existing images with AI
- Needs to edit specific regions of images (inpainting)
- Wants to create images with specific styles (vector, realistic, typography)
- Needs high-resolution professional images (up to 2K)
- Wants to use a reference image for style transfer
- Mentions specific models like FLUX, Recraft, or Imagen
- Asks for logo, poster, or brand-style image generation
- Needs object removal or targeted modifications
Quick Start
Text-to-Image: Generate from Scratch
CODEBLOCK0
Image Remix: Transform Existing Images
CODEBLOCK1
Image Edit: Targeted Modifications
CODEBLOCK2
Model Selection Guide
The script intelligently selects the best model based on task context:
flux-pro/v1.1-ultra (Default for High-Res)
- - Best for: Professional photography, high-resolution outputs (up to 2K)
- Strengths: Photo realism, professional quality
- Use when: User needs publication-ready images
- Endpoint: INLINECODE0
recraft/v3/text-to-image (SOTA Quality)
- - Best for: Typography, vector art, brand-style images, long text
- Strengths: Industry-leading benchmark scores, precise text rendering
- Use when: Creating logos, posters, or text-heavy designs
- Endpoint: INLINECODE1
flux-2 (Best Balance)
- - Best for: General-purpose image generation
- Strengths: Enhanced realism, crisp text, native editing
- Use when: Standard image generation needs
- Endpoint: INLINECODE2
flux-2/lora (Custom Styles)
- - Best for: Domain-specific styles, fine-tuned variations
- Strengths: Custom style adaptation
- Use when: User wants specific artistic styles
- Endpoint: INLINECODE3
flux-2/lora/edit (Style Transfer)
- - Best for: Image-to-image editing with style references
- Strengths: Specialized style transfer
- Use when: User provides reference image with
-i flag - Endpoint: INLINECODE5
imagen4/preview (Google Quality)
- - Best for: High-quality general images
- Strengths: Google's highest quality model
- Use when: User specifically requests Imagen or Google models
- Endpoint: INLINECODE6
stable-diffusion-v35-large (Typography & Style)
- - Best for: Complex prompts, typography, style control
- Strengths: Advanced prompt understanding, resource efficiency
- Use when: Complex multi-element compositions
- Endpoint: INLINECODE7
ideogram/v2 (Typography Specialist)
- - Best for: Posters, logos, text-heavy designs
- Strengths: Exceptional typography, realistic outputs
- Use when: Text accuracy is critical
- Endpoint: INLINECODE8
bria/text-to-image/3.2 (Commercial Safe)
- - Best for: Commercial projects requiring licensed training data
- Strengths: Safe for commercial use, excellent text rendering
- Use when: Legal/licensing concerns matter
- Endpoint: INLINECODE9
Command-Line Interface
CODEBLOCK3
Authentication Setup
Before first use, set your fal.ai API key:
CODEBLOCK4
Or create a .env file in the skill directory:
CODEBLOCK5
Get your API key from: https://fal.ai/dashboard/keys
Advanced Examples
High-Resolution Professional Photo
CODEBLOCK6
Logo/Typography Design
CODEBLOCK7
Style Transfer from Reference
CODEBLOCK8
Reproducible Generation
CODEBLOCK9
Model Selection Logic
The script automatically selects the best model when -m is not specified:
- 1. If
-i provided: Uses flux-2/lora/edit for style transfer - If prompt contains typography keywords (logo, text, poster, sign): Uses INLINECODE14
- If prompt suggests high-res needs (professional, portrait, headshot): Uses INLINECODE15
- If prompt mentions vector/brand: Uses INLINECODE16
- Default: Uses
flux-2 for general purpose
Output Format
Generated images are saved with metadata:
- - Filename includes timestamp and model name
- EXIF data stores prompt, model, and parameters
- Console displays generation time and cost estimate
Troubleshooting
| Problem | Solution |
|---|
| INLINECODE18 | Export FAL_KEY environment variable or create .env file |
| INLINECODE19 |
Check model name against supported list |
|
Image reference fails | Ensure image path/URL is accessible |
|
Generation timeout | Some models take longer; wait or try faster model |
|
Rate limit error | Check fal.ai dashboard for usage limits |
Cost Optimization
- - Free tier: FLUX.2 offers 100 free requests (expires Dec 25, 2025)
- Pay per use: FLUX Pro charges per megapixel
- Budget option: Use
flux-2 or stable-diffusion-v35-large for general use - Premium: Use
flux-pro/v1.1-ultra only when high-res is required
Image Remix: Model Selection Guide
Available models for image-to-image remixing:
flux-2/dev (Default, Free)
- - Best for: General remixing, style transfer, fast iteration
- Strengths: Balanced quality/speed, 100 free requests
- Use when: Standard remixing needs
- Endpoint: INLINECODE26
flux-pro (Premium Quality)
- - Best for: Professional remixing, high-quality outputs
- Strengths: Superior quality, realistic transformations
- Use when: Professional or publication-ready remixes
- Endpoint: INLINECODE27
flux-1.1-pro (Ultra Premium)
- - Best for: Highest quality remixing with maximum detail
- Strengths: Ultra-high quality, exceptional detail preservation
- Use when: Premium projects requiring best possible output
- Endpoint: INLINECODE28
recraft/v3 (Vector/Illustration)
- - Best for: Vector style, brand imagery, illustration remixing
- Strengths: Clean vector outputs, brand-style transformations
- Use when: Converting to illustration or vector style
- Endpoint: INLINECODE29
stable-diffusion-v35 (Artistic)
- - Best for: Artistic styles, painting effects, creative remixing
- Strengths: Strong artistic style application
- Use when: Artistic or stylized transformations
- Endpoint: INLINECODE30
Image Remix: Command-Line Interface
CODEBLOCK10
Remix Strength Guide
The --strength parameter controls transformation intensity:
| Strength | Effect | Use Case |
|---|
| 0.3-0.5 | Subtle changes | Minor color adjustments, lighting tweaks |
| 0.5-0.7 |
Moderate changes | Style hints while preserving details |
| 0.7-0.85 | Strong changes | Clear style transfer, significant transformation |
| 0.85-1.0 | Maximum changes | Complete style overhaul, dramatic transformation |
Remix Examples
CODEBLOCK11
Image Edit: Model Selection Guide
Available models for targeted editing and inpainting:
flux-2/redux (General Editing)
- - Best for: General image editing without masks
- Strengths: Fast, balanced, good for overall adjustments
- Use when: No specific region targeting needed
- Endpoint: INLINECODE32
flux-2/fill (Inpainting, Default)
- - Best for: Masked region editing, object removal, filling
- Strengths: Seamless inpainting, natural blending
- Use when: Editing specific masked regions
- Endpoint: INLINECODE33
flux-pro-v11/fill (Premium Inpainting)
- - Best for: Professional inpainting with highest quality
- Strengths: Superior quality, professional results
- Use when: Premium quality inpainting required
- Endpoint: INLINECODE34
stable-diffusion-v35/inpainting (Artistic Inpainting)
- - Best for: Artistic edits, creative inpainting
- Strengths: Strong artistic control, detailed generation
- Use when: Artistic or stylized edits
- Endpoint: INLINECODE35
ideogram/v2/edit (Realistic Editing)
- - Best for: Realistic modifications, precise edits
- Strengths: High realism, precise control
- Use when: Realistic edits required
- Endpoint: INLINECODE36
recraft/v3/svg (Vector Editing)
- - Best for: Vector style edits, clean illustrations
- Strengths: Clean vector outputs, illustration style
- Use when: Vector or illustration edits
- Endpoint: INLINECODE37
Image Edit: Command-Line Interface
CODEBLOCK12
Edit Strength Guide
The --strength parameter controls edit intensity:
| Strength | Effect | Use Case |
|---|
| 0.5-0.7 | Subtle edits | Minor touch-ups, color adjustments |
| 0.7-0.9 |
Moderate edits | Clear modifications while blending naturally |
| 0.9-1.0 | Strong edits | Complete replacement, object removal |
Creating Mask Images
Mask images define edit regions:
- - White (255): Areas to edit/modify
- Black (0): Areas to preserve unchanged
- Gray: Partial blending (proportional to brightness)
Create masks using:
- - Image editors (GIMP, Photoshop, Krita)
- Paint tools (select and fill with white/black)
- Text-based prompts (
--mask-prompt flag)
Edit Examples
CODEBLOCK13
File Structure
CODEBLOCK14
Dependencies
Managed via uv:
- -
fal-client: Official fal.ai Python SDK - INLINECODE42 : Environment variable management
- INLINECODE43 : Image handling and EXIF metadata
- INLINECODE44 : CLI interface
Best Practices
General
- 1. Model Selection: Let scripts auto-select unless you have specific needs
- Prompt Engineering: Be specific and descriptive for better outputs
- Cost Awareness: Monitor usage on fal.ai dashboard
- Reproducibility: Use
--seed for consistent results during iteration
Text-to-Image
- 1. Reference Images: Use high-quality references for best style transfer results
- Size Selection: Match aspect ratio to intended use (square, landscape, portrait)
- Model Choice: Use recraft/v3 for typography, flux-pro for professional photography
Image Remix
- 1. Strength Tuning: Start with default (0.75), adjust based on desired transformation
- Source Quality: Higher quality source images produce better remixes
- Iteration: Use --seed to iterate on same generation with different prompts
- Balance: Lower strength preserves more detail, higher creates more dramatic changes
Image Edit
- 1. Mask Quality: Clean, well-defined masks produce better results
- Mask Creation: Use image editors for precise control, --mask-prompt for quick tests
- Blending: Use gray tones in masks for smooth transitions
- Edit Strength: Use 0.95+ for object removal, 0.7-0.9 for modifications
- Test First: Try --mask-prompt before creating detailed masks
- Multiple Edits: Edit in stages rather than all at once for complex modifications
Resources
- - fal.ai Documentation: https://docs.fal.ai/
- Model Playground: https://fal.ai/explore/search
- API Keys: https://fal.ai/dashboard/keys
- Pricing: https://fal.ai/pricing
Workflow Examples
Complete Image Creation Pipeline
CODEBLOCK15
Iterative Refinement
CODEBLOCK16
Object Removal and Replacement
CODEBLOCK17
Troubleshooting
| Problem | Solution | Tool |
|---|
| INLINECODE46 | Export FAL_KEY or create .env file | All |
| INLINECODE47 |
Check model name in documentation | All |
|
Image upload fails | Check file exists and is readable | Remix, Edit |
|
Mask not working | Verify mask is grayscale PNG (white=edit) | Edit |
|
Transformation too strong | Reduce --strength value | Remix, Edit |
|
Transformation too weak | Increase --strength value | Remix, Edit |
|
Mask-prompt not precise | Create manual mask in image editor | Edit |
|
Generation timeout | Try faster model or wait longer | All |
|
Rate limit error | Check fal.ai dashboard usage limits | All |
Limitations
General
- - Requires active fal.ai API key
- Subject to fal.ai rate limits and quotas
- Internet connection required
- Some models have usage costs (check pricing)
Text-to-Image
- - Image reference features limited to specific models
- Typography quality varies by model
Image Remix
- - Source image quality affects output quality
- Extreme strength values may introduce artifacts
- Some styles work better with specific models
Image Edit
- - Mask quality critical for seamless results
- Auto-generated masks (--mask-prompt) less precise than manual masks
- Complex edits may require multiple passes
- Some models don't support all editing features
fal.ai 图像生成与编辑技能
使用 fal.ai 最先进的模型(包括 FLUX、Recraft V3、Imagen4 等)进行专业 AI 驱动的图像工作流。
三种操作模式
1. 文生图(fal-text-to-image)
使用文本提示从头生成图像
2. 图像重混(fal-image-remix)
在保留构图的同时转换现有图像
3. 图像编辑(fal-image-edit)
定向修复和蒙版编辑
何时使用此技能
当用户出现以下情况时触发:
- - 请求根据文本描述生成图像
- 想要使用 AI 转换/重混现有图像
- 需要编辑图像的特定区域(修复)
- 想要创建特定风格的图像(矢量、写实、排版)
- 需要高分辨率专业图像(最高 2K)
- 想要使用参考图像进行风格迁移
- 提及特定模型如 FLUX、Recraft 或 Imagen
- 要求生成 Logo、海报或品牌风格图像
- 需要移除物体或定向修改
快速入门
文生图:从头生成
bash
基础生成
uv run python fal-text-to-image 日落时分霓虹灯闪烁的赛博朋克城市
使用特定模型
uv run python fal-text-to-image -m flux-pro/v1.1-ultra 专业头像照
使用风格参考
uv run python fal-text-to-image -i reference.jpg 山地景观 -m flux-2/lora/edit
图像重混:转换现有图像
bash
在保留构图的同时转换风格
uv run python fal-image-remix input.jpg 转换为油画风格
带强度控制(0.0=原始,1.0=完全转换)
uv run python fal-image-remix photo.jpg 动漫风格角色 --strength 0.6
高级质量重混
uv run python fal-image-remix -m flux-1.1-pro image.jpg 专业肖像照
图像编辑:定向修改
bash
使用蒙版图像编辑(白色=编辑区域,黑色=保留区域)
uv run python fal-image-edit input.jpg mask.png 替换为花朵
从文本自动生成蒙版
uv run python fal-image-edit input.jpg --mask-prompt 天空 改为日落效果
移除物体
uv run python fal-image-edit photo.jpg mask.png 移除物体 --strength 1.0
通用编辑(无蒙版)
uv run python fal-image-edit photo.jpg 增强光照和色彩
模型选择指南
脚本会根据任务上下文智能选择最佳模型:
flux-pro/v1.1-ultra(高分辨率默认)
- - 最佳用途:专业摄影、高分辨率输出(最高 2K)
- 优势:照片级写实、专业质量
- 使用场景:用户需要可出版级图像
- 端点:fal-ai/flux-pro/v1.1-ultra
recraft/v3/text-to-image(SOTA 质量)
- - 最佳用途:排版、矢量艺术、品牌风格图像、长文本
- 优势:行业领先的基准分数、精确的文本渲染
- 使用场景:创建 Logo、海报或文本密集型设计
- 端点:fal-ai/recraft/v3/text-to-image
flux-2(最佳平衡)
- - 最佳用途:通用图像生成
- 优势:增强的写实感、清晰的文本、原生编辑
- 使用场景:标准图像生成需求
- 端点:fal-ai/flux-2
flux-2/lora(自定义风格)
- - 最佳用途:特定领域风格、微调变体
- 优势:自定义风格适配
- 使用场景:用户想要特定艺术风格
- 端点:fal-ai/flux-2/lora
flux-2/lora/edit(风格迁移)
- - 最佳用途:带风格参考的图像到图像编辑
- 优势:专业风格迁移
- 使用场景:用户使用 -i 标志提供参考图像
- 端点:fal-ai/flux-2/lora/edit
imagen4/preview(谷歌质量)
- - 最佳用途:高质量通用图像
- 优势:谷歌最高质量模型
- 使用场景:用户特别要求 Imagen 或谷歌模型
- 端点:fal-ai/imagen4/preview
stable-diffusion-v35-large(排版与风格)
- - 最佳用途:复杂提示、排版、风格控制
- 优势:高级提示理解、资源效率
- 使用场景:复杂多元素构图
- 端点:fal-ai/stable-diffusion-v35-large
ideogram/v2(排版专家)
- - 最佳用途:海报、Logo、文本密集型设计
- 优势:卓越的排版、写实输出
- 使用场景:文本准确性至关重要
- 端点:fal-ai/ideogram/v2
bria/text-to-image/3.2(商业安全)
- - 最佳用途:需要许可训练数据的商业项目
- 优势:商业使用安全、出色的文本渲染
- 使用场景:法律/许可问题重要
- 端点:fal-ai/bria/text-to-image/3.2
命令行界面
bash
uv run python fal-text-to-image [选项] 提示词
参数:
提示词 要生成图像的文本描述
选项:
-m, --model 文本 要使用的模型(见上方模型列表)
-i, --image 文本 用于风格迁移的参考图像路径或 URL
-o, --output 文本 输出文件名(默认:generated_image.png)
-s, --size 文本 图像尺寸(例如:1024x1024、landscape169)
--seed 整数 用于可复现性的随机种子
--steps 整数 推理步数(取决于模型)
--guidance 浮点数 引导比例(越高=越遵循提示)
--help 显示此消息并退出
身份验证设置
首次使用前,设置您的 fal.ai API 密钥:
bash
export FAL_KEY=your-api-key-here
或在技能目录中创建 .env 文件:
env
FAL_KEY=your-api-key-here
从以下地址获取您的 API 密钥:https://fal.ai/dashboard/keys
高级示例
高分辨率专业照片
bash
uv run python fal-text-to-image \
-m flux-pro/v1.1-ultra \
现代办公室中企业高管的专业头像照 \
-s 2048x2048
Logo/排版设计
bash
uv run python fal-text-to-image \
-m recraft/v3/text-to-image \
现代科技初创公司 Logo,文字 AI Labs,极简风格
参考图像风格迁移
bash
uv run python fal-text-to-image \
-m flux-2/lora/edit \
-i artistic_style.jpg \
花园中的女性肖像
可复现生成
bash
uv run python fal-text-to-image \
-m flux-2 \
--seed 42 \
带有飞行汽车的未来城市景观
模型选择逻辑
当未指定 -m 时,脚本会自动选择最佳模型:
- 1. 如果提供了 -i:使用 flux-2/lora/edit 进行风格迁移
- 如果提示包含排版关键词(logo、文字、海报、标志):使用 recraft/v3/text-to-image
- 如果提示暗示高分辨率需求(专业、肖像、头像):使用 flux-pro/v1.1-ultra
- 如果提示提及矢量/品牌:使用 recraft/v3/text-to-image
- 默认:使用 flux-2 进行通用生成
输出格式
生成的图像保存时包含元数据:
- - 文件名包含时间戳和模型名称
- EXIF 数据存储提示词、模型和参数
- 控制台显示生成时间和成本估算
故障排除
| 问题 | 解决方案 |
|---|
| FALKEY 未设置 | 导出 FALKEY 环境变量或创建 .env 文件 |
| 未找到模型 |
对照支持的模型列表检查模型名称 |
| 图像参考失败 | 确保图像路径/URL 可访问 |
| 生成超时 | 某些模型需要更长时间;等待或尝试更快的模型 |
| 速率限制错误 | 在 fal.ai 仪表板检查使用限制 |
成本优化
- - 免费层:FLUX.2 提供 100 次免费请求(2025 年 12 月 25