fal.ai

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

fal.ai Image Generator

fal.ai 图像生成工具

Use the fal.ai API to generate images from text prompts.
Official docs:
https://fal.ai/docs

使用fal.ai API根据文本提示词生成图像
官方文档:
https://fal.ai/docs

When to Use

适用场景

Use this skill when you need to:
  • Generate images from text descriptions
  • Create illustrations or visual content
  • Generate blog headers, thumbnails, or social media images

当你需要以下操作时,可使用此技能:
  • 根据文本描述生成图像
  • 创建插画或视觉内容
  • 生成博客标题图、缩略图或社交媒体图片

Prerequisites

前置条件

  1. Sign up at fal.ai
  2. Get your API key from the dashboard
bash
export FAL_KEY="your-api-key"

Important: When using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
  1. fal.ai注册账号
  2. 从控制台获取你的API密钥
bash
export FAL_KEY="your-api-key"

重要提示: 在包含
$VAR
的命令中如果需要通过管道符传递给其他命令,请将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的一个bug,当直接使用管道符时,环境变量会被自动清除。
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'

How to Use

使用方法

1. Generate Image (nano-banana-pro - fast)

1. 生成图像(nano-banana-pro - 快速版)

Write to
/tmp/fal_request.json
:
json
{
  "prompt": "A futuristic city at sunset, cyberpunk style"
}
Then run:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
编写内容到
/tmp/fal_request.json
json
{
  "prompt": "A futuristic city at sunset, cyberpunk style"
}
然后运行:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

2. Generate Image (flux/schnell - fast)

2. 生成图像(flux/schnell - 快速版)

Write to
/tmp/fal_request.json
:
json
{
  "prompt": "A cute cat eating a cookie"
}
Then run:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/flux/schnell" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
编写内容到
/tmp/fal_request.json
json
{
  "prompt": "A cute cat eating a cookie"
}
然后运行:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/flux/schnell" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

3. Generate Image (recraft-v3 - high quality)

3. 生成图像(recraft-v3 - 高质量版)

Write to
/tmp/fal_request.json
:
json
{
  "prompt": "Abstract art, vibrant colors"
}
Then run:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/recraft-v3" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
编写内容到
/tmp/fal_request.json
json
{
  "prompt": "Abstract art, vibrant colors"
}
然后运行:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/recraft-v3" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

4. Generate with Custom Size

4. 自定义尺寸生成图像

Write to
/tmp/fal_request.json
:
json
{
  "prompt": "Mountain landscape",
  "image_size": "landscape_16_9"
}
Then run:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
编写内容到
/tmp/fal_request.json
json
{
  "prompt": "Mountain landscape",
  "image_size": "landscape_16_9"
}
然后运行:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

5. Download Generated Image

5. 下载生成的图像

Write to
/tmp/fal_request.json
:
json
{
  "prompt": "A minimalist workspace"
}
Then run:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url' | xargs curl -sL -o /tmp/image.png
编写内容到
/tmp/fal_request.json
json
{
  "prompt": "A minimalist workspace"
}
然后运行:
bash
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url' | xargs curl -sL -o /tmp/image.png

6. Pipe Prompt from Echo (JSON escaped)

6. 通过Echo传递提示词(JSON转义)

bash
echo "A dragon breathing fire, epic fantasy art" | jq -Rs '{prompt: .}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
bash
echo "A dragon breathing fire, epic fantasy art" | jq -Rs '{prompt: .}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

7. Pipe Prompt from File (JSON escaped)

7. 通过文件传递提示词(JSON转义)

bash
cat /tmp/prompt.txt | jq -Rs '{prompt: .}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'
bash
cat /tmp/prompt.txt | jq -Rs '{prompt: .}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

8. Pipe with Additional Parameters

8. 传递提示词并附加参数

bash
echo "Neon city at night" | jq -Rs '{prompt: ., image_size: "landscape_16_9"}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

bash
echo "Neon city at night" | jq -Rs '{prompt: ., image_size: "landscape_16_9"}' > /tmp/fal_request.json
bash -c 'curl -s -X POST "https://fal.run/fal-ai/nano-banana-pro" --header "Authorization: Key ${FAL_KEY}" --header "Content-Type: application/json" -d @/tmp/fal_request.json' | jq -r '.images[0].url'

Available Models

可用模型

ModelDescription
nano-banana-pro
Fast, good quality (recommended)
flux/schnell
Fast generation
flux-pro
High quality
recraft-v3
High quality vector/illustration

模型描述
nano-banana-pro
快速生成,画质优秀(推荐)
flux/schnell
快速生成
flux-pro
高质量
recraft-v3
高质量矢量/插画
更多模型请查看:https://fal.ai/models

Image Sizes

图像尺寸

SizeAspect Ratio
square
1:1
square_hd
1:1 (high res)
portrait_4_3
4:3
portrait_16_9
16:9
landscape_4_3
3:4
landscape_16_9
9:16

尺寸宽高比
square
1:1
square_hd
1:1(高分辨率)
portrait_4_3
4:3
portrait_16_9
16:9
landscape_4_3
3:4
landscape_16_9
9:16

Prompt Guidelines

提示词撰写指南

For best results:
  1. Be specific - Describe the subject clearly
  2. Add style hints - "modern", "minimalist", "photorealistic", "digital art", "cinematic"
  3. Specify colors/mood - "blue and purple gradient", "warm tones", "dark and moody"
  4. Keep it concise - Clear and focused descriptions work better
为获得最佳效果:
  1. 描述具体 - 清晰描述主体
  2. 添加风格提示 - 例如“现代风”、“极简主义”、“照片写实”、“数字艺术”、“电影质感”
  3. 指定色彩/氛围 - 例如“蓝紫渐变”、“暖色调”、“暗黑氛围感”
  4. 简洁明了 - 清晰聚焦的描述效果更佳