fal-text-to-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

fal.ai Text-to-Image Generation Skill

fal.ai 文本生成图像技能

Generate production-quality images from text prompts using fal.ai's state-of-the-art text-to-image models including FLUX, Recraft V3, Imagen4, and more.
借助fal.ai的前沿文本生成图像模型(包括FLUX、Recraft V3、Imagen4等),生成可用于生产环境的图像。

When to Use This Skill

何时使用该技能

Trigger when user:
  • Requests image generation from text descriptions
  • 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
当用户有以下需求时触发:
  • 要求根据文本描述生成图像
  • 想要创建具有特定风格的图像(矢量风、写实风、排版设计)
  • 需要高分辨率的专业图像(最高可达2K)
  • 希望使用参考图像进行风格迁移
  • 提到特定模型,如FLUX、Recraft或Imagen
  • 请求生成logo、海报或品牌风格的图像

Quick Start

快速开始

Basic Usage

基础用法

bash
uv run python fal-text-to-image "A cyberpunk city at sunset with neon lights"
bash
uv run python fal-text-to-image "A cyberpunk city at sunset with neon lights"

With Specific Model

使用指定模型

bash
uv run python fal-text-to-image -m flux-pro/v1.1-ultra "Professional headshot of a business executive"
bash
uv run python fal-text-to-image -m flux-pro/v1.1-ultra "Professional headshot of a business executive"

With Style Reference Image

使用风格参考图像

bash
uv run python fal-text-to-image -i reference.jpg "A mountain landscape" -m flux-2/lora/edit
bash
uv run python fal-text-to-image -i reference.jpg "A mountain landscape" -m flux-2/lora/edit

Model Selection Guide

模型选择指南

The script intelligently selects the best model based on task context:
脚本会根据任务上下文智能选择最佳模型:

flux-pro/v1.1-ultra (Default for High-Res)

flux-pro/v1.1-ultra(高分辨率默认模型)

  • Best for: Professional photography, high-resolution outputs (up to 2K)
  • Strengths: Photo realism, professional quality
  • Use when: User needs publication-ready images
  • Endpoint:
    fal-ai/flux-pro/v1.1-ultra
  • 最佳适用场景:专业摄影、高分辨率输出(最高2K)
  • 优势:照片级写实、专业品质
  • 使用时机:用户需要可用于出版的图像
  • 端点
    fal-ai/flux-pro/v1.1-ultra

recraft/v3/text-to-image (SOTA Quality)

recraft/v3/text-to-image(业界顶尖品质)

  • 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:
    fal-ai/recraft/v3/text-to-image
  • 最佳适用场景:排版设计、矢量艺术、品牌风格图像、长文本内容
  • 优势:业界领先的基准测试分数、精准的文本渲染
  • 使用时机:创建logo、海报或文本密集型设计
  • 端点
    fal-ai/recraft/v3/text-to-image

flux-2 (Best Balance)

flux-2(平衡之选)

  • Best for: General-purpose image generation
  • Strengths: Enhanced realism, crisp text, native editing
  • Use when: Standard image generation needs
  • Endpoint:
    fal-ai/flux-2
  • 最佳适用场景:通用图像生成
  • 优势:增强的写实感、清晰的文本、原生编辑功能
  • 使用时机:标准图像生成需求
  • 端点
    fal-ai/flux-2

flux-2/lora (Custom Styles)

flux-2/lora(自定义风格)

  • Best for: Domain-specific styles, fine-tuned variations
  • Strengths: Custom style adaptation
  • Use when: User wants specific artistic styles
  • Endpoint:
    fal-ai/flux-2/lora
  • 最佳适用场景:特定领域风格、微调变体
  • 优势:适配自定义风格
  • 使用时机:用户想要特定艺术风格
  • 端点
    fal-ai/flux-2/lora

flux-2/lora/edit (Style Transfer)

flux-2/lora/edit(风格迁移)

  • Best for: Image-to-image editing with style references
  • Strengths: Specialized style transfer
  • Use when: User provides reference image with
    -i
    flag
  • Endpoint:
    fal-ai/flux-2/lora/edit
  • 最佳适用场景:基于参考图像的图像到图像编辑
  • 优势:专业风格迁移
  • 使用时机:用户通过
    -i
    参数提供参考图像时
  • 端点
    fal-ai/flux-2/lora/edit

imagen4/preview (Google Quality)

imagen4/preview(谷歌品质)

  • Best for: High-quality general images
  • Strengths: Google's highest quality model
  • Use when: User specifically requests Imagen or Google models
  • Endpoint:
    fal-ai/imagen4/preview
  • 最佳适用场景:高质量通用图像
  • 优势:谷歌旗下最高品质模型
  • 使用时机:用户明确要求Imagen或谷歌模型时
  • 端点
    fal-ai/imagen4/preview

stable-diffusion-v35-large (Typography & Style)

stable-diffusion-v35-large(排版与风格控制)

  • Best for: Complex prompts, typography, style control
  • Strengths: Advanced prompt understanding, resource efficiency
  • Use when: Complex multi-element compositions
  • Endpoint:
    fal-ai/stable-diffusion-v35-large
  • 最佳适用场景:复杂提示、排版设计、风格控制
  • 优势:高级提示理解、资源高效
  • 使用时机:复杂多元素构图
  • 端点
    fal-ai/stable-diffusion-v35-large

ideogram/v2 (Typography Specialist)

ideogram/v2(排版专家)

  • Best for: Posters, logos, text-heavy designs
  • Strengths: Exceptional typography, realistic outputs
  • Use when: Text accuracy is critical
  • Endpoint:
    fal-ai/ideogram/v2
  • 最佳适用场景:海报、logo、文本密集型设计
  • 优势:卓越的排版效果、写实输出
  • 使用时机:文本准确性至关重要时
  • 端点
    fal-ai/ideogram/v2

bria/text-to-image/3.2 (Commercial Safe)

bria/text-to-image/3.2(商业安全合规)

  • Best for: Commercial projects requiring licensed training data
  • Strengths: Safe for commercial use, excellent text rendering
  • Use when: Legal/licensing concerns matter
  • Endpoint:
    fal-ai/bria/text-to-image/3.2
  • 最佳适用场景:需要授权训练数据的商业项目
  • 优势:可安全用于商业用途、优秀的文本渲染
  • 使用时机:存在法律/授权顾虑时
  • 端点
    fal-ai/bria/text-to-image/3.2

Command-Line Interface

命令行界面

bash
uv run python fal-text-to-image [OPTIONS] PROMPT

Arguments:
  PROMPT                    Text description of the image to generate

Options:
  -m, --model TEXT         Model to use (see model list above)
  -i, --image TEXT         Path or URL to reference image for style transfer
  -o, --output TEXT        Output filename (default: generated_image.png)
  -s, --size TEXT          Image size (e.g., "1024x1024", "landscape_16_9")
  --seed INTEGER           Random seed for reproducibility
  --steps INTEGER          Number of inference steps (model-dependent)
  --guidance FLOAT         Guidance scale (higher = more prompt adherence)
  --help                   Show this message and exit
bash
uv run python fal-text-to-image [OPTIONS] PROMPT

Arguments:
  PROMPT                    要生成的图像的文本描述

Options:
  -m, --model TEXT         要使用的模型(参见上方模型列表)
  -i, --image TEXT         用于风格迁移的参考图像路径或URL
  -o, --output TEXT        输出文件名(默认值:generated_image.png)
  -s, --size TEXT          图像尺寸(例如:"1024x1024", "landscape_16_9"  --seed INTEGER           用于结果复现的随机种子
  --steps INTEGER          推理步数(取决于模型)
  --guidance FLOAT         引导尺度(值越高,越贴合提示文本)
  --help                   显示此帮助信息并退出

Authentication Setup

认证设置

Before first use, set your fal.ai API key:
bash
export FAL_KEY="your-api-key-here"
Or create a
.env
file in the skill directory:
env
FAL_KEY=your-api-key-here
Get your API key from: https://fal.ai/dashboard/keys
首次使用前,请设置你的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

Advanced Examples

进阶示例

High-Resolution Professional Photo

高分辨率专业照片

bash
uv run python fal-text-to-image \
  -m flux-pro/v1.1-ultra \
  "Professional headshot of a business executive in modern office" \
  -s 2048x2048
bash
uv run python fal-text-to-image \
  -m flux-pro/v1.1-ultra \
  "Professional headshot of a business executive in modern office" \
  -s 2048x2048

Logo/Typography Design

Logo/排版设计

bash
uv run python fal-text-to-image \
  -m recraft/v3/text-to-image \
  "Modern tech startup logo with text 'AI Labs' in minimalist style"
bash
uv run python fal-text-to-image \
  -m recraft/v3/text-to-image \
  "Modern tech startup logo with text 'AI Labs' in minimalist style"

Style Transfer from Reference

基于参考图像的风格迁移

bash
uv run python fal-text-to-image \
  -m flux-2/lora/edit \
  -i artistic_style.jpg \
  "Portrait of a woman in a garden"
bash
uv run python fal-text-to-image \
  -m flux-2/lora/edit \
  -i artistic_style.jpg \
  "Portrait of a woman in a garden"

Reproducible Generation

可复现的图像生成

bash
uv run python fal-text-to-image \
  -m flux-2 \
  --seed 42 \
  "Futuristic cityscape with flying cars"
bash
uv run python fal-text-to-image \
  -m flux-2 \
  --seed 42 \
  "Futuristic cityscape with flying cars"

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
  2. If prompt contains typography keywords (logo, text, poster, sign): Uses
    recraft/v3/text-to-image
  3. If prompt suggests high-res needs (professional, portrait, headshot): Uses
    flux-pro/v1.1-ultra
  4. If prompt mentions vector/brand: Uses
    recraft/v3/text-to-image
  5. Default: Uses
    flux-2
    for general purpose
当未指定
-m
参数时,脚本会自动选择最佳模型:
  1. 如果提供了
    -i
    参数
    :使用
    flux-2/lora/edit
    进行风格迁移
  2. 如果提示包含排版相关关键词(logo、text、poster、sign):使用
    recraft/v3/text-to-image
  3. 如果提示表明需要高分辨率(professional、portrait、headshot):使用
    flux-pro/v1.1-ultra
  4. 如果提示提到vector/brand:使用
    recraft/v3/text-to-image
  5. 默认情况:使用
    flux-2
    进行通用图像生成

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
生成的图像会附带元数据保存:
  • 文件名包含时间戳和模型名称
  • EXIF数据存储提示文本、模型及参数
  • 控制台会显示生成时间和成本估算

Troubleshooting

故障排查

ProblemSolution
FAL_KEY not set
Export FAL_KEY environment variable or create .env file
Model not found
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
问题解决方案
FAL_KEY not set
导出FAL_KEY环境变量或创建.env文件
Model not found
对照支持的模型列表检查模型名称
Image reference fails
确保图像路径/URL可访问
Generation timeout
部分模型生成时间较长,请等待或尝试更快的模型
Rate limit error
查看fal.ai控制台的使用限制

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
  • 免费额度:FLUX.2提供100次免费请求(有效期至2025年12月25日)
  • 按使用付费:FLUX Pro按每百万像素收费
  • 预算友好选项:通用场景使用
    flux-2
    stable-diffusion-v35-large
  • 高端需求:仅在需要高分辨率时使用
    flux-pro/v1.1-ultra

File Structure

文件结构

fal-text-to-image/
├── SKILL.md                    # This file
├── pyproject.toml              # Dependencies (uv)
├── fal-text-to-image           # Main executable script
├── references/
│   └── model-comparison.md     # Detailed model benchmarks
└── outputs/                    # Generated images (created on first run)
fal-text-to-image/
├── SKILL.md                    # 本文件
├── pyproject.toml              # 依赖配置(uv)
├── fal-text-to-image           # 主可执行脚本
├── references/
│   └── model-comparison.md     # 详细模型基准测试
└── outputs/                    # 生成的图像(首次运行时创建)

Dependencies

依赖项

Managed via
uv
:
  • fal-client
    : Official fal.ai Python SDK
  • python-dotenv
    : Environment variable management
  • pillow
    : Image handling and EXIF metadata
  • click
    : CLI interface
通过
uv
管理:
  • fal-client
    : fal.ai官方Python SDK
  • python-dotenv
    : 环境变量管理
  • pillow
    : 图像处理与EXIF元数据
  • click
    : 命令行界面框架

Best Practices

最佳实践

  1. Model Selection: Let the script auto-select unless you have specific needs
  2. Reference Images: Use high-quality references for best style transfer results
  3. Prompt Engineering: Be specific and descriptive for better outputs
  4. Cost Awareness: Monitor usage on fal.ai dashboard
  5. Reproducibility: Use
    --seed
    for consistent results during iteration
  1. 模型选择:除非有特定需求,否则让脚本自动选择模型
  2. 参考图像:使用高质量参考图像以获得最佳风格迁移效果
  3. 提示词优化:提示词要具体、描述性强,以获得更好的输出
  4. 成本意识:在fal.ai控制台监控使用情况
  5. 结果复现:使用
    --seed
    参数在迭代过程中获得一致结果

Resources

资源

Limitations

局限性

  • Requires active fal.ai API key
  • Subject to fal.ai rate limits and quotas
  • Internet connection required
  • Some models have usage costs (check pricing)
  • Image reference features limited to specific models
  • 需要有效的fal.ai API密钥
  • 受fal.ai的速率限制和配额约束
  • 需要互联网连接
  • 部分模型会产生使用成本(请查看定价)
  • 图像参考功能仅适用于特定模型