Fal Image Gen
Overview
Use this skill to implement text-to-image or image-to-image calls against fal model APIs. Prioritize correctness by checking the current docs for the selected model’s required inputs/outputs and authentication requirements.
Quick Start
- 1. Identify the target model ID from the fal model API docs.
- Collect inputs from the user.
- - Text-to-image:
prompt, optional negative_prompt, size/aspect, steps, seed, safety options. - Image-to-image: source image URL, strength/denoise, plus prompt/options above.
- 3. Pick the calling method.
- - If the user prefers SDKs: provide Python and/or JavaScript examples.
- If the user prefers REST: provide a curl/HTTP example.
- 4. Execute the request and return image URL(s) from the response.
Workflow: Text-to-Image
- 1. Resolve the model ID and schema.
- - Open the fal model API docs and confirm the exact input fields and output format.
- 2. Validate inputs.
- - Ensure prompt is non-empty and size/aspect settings are supported by the model.
- 3. Build the request.
- - SDK: call the SDK’s
run/submit method with an input object. - REST: call the model endpoint with a JSON body that matches the schema.
- 4. Execute and parse output.
- - Extract image URL(s) from the response fields defined by the model.
- 5. Return URLs.
- - Provide a clean list of URLs and note any metadata the user asked for (seed, size, etc.).
Workflow: Image-to-Image
- 1. Resolve the model ID and schema.
- Validate inputs.
- - Ensure the source image is reachable by URL (or converted to the required format).
- Confirm any strength/denoise range constraints from docs.
- 3. Build the request.
- - Include source image + prompt + other options as required by the model.
- 4. Execute and parse output.
- - Extract image URL(s) from the response fields defined by the model.
- 5. Return URLs.
SDK vs REST Guidance
- - Prefer SDKs for simpler auth and retries.
- Prefer REST when the user needs raw HTTP examples, or when running in environments without SDK support.
- Never hardcode API keys. Follow the docs for the required environment variable or header name.
Minimal Examples (Fill From Docs)
Use these as templates only. Replace placeholders after checking the docs.
Python (SDK)
CODEBLOCK0
JavaScript (SDK)
CODEBLOCK1
REST (curl)
CODEBLOCK2
Resources
- -
references/fal-model-api-checklist.md: Checklist for gathering inputs and validating responses. - INLINECODE6 : Example templates for text-to-image, image-to-image, and REST usage.
Fal 图像生成
概述
使用此技能实现针对 fal 模型 API 的文本转图像或图像转图像调用。通过查阅所选模型当前文档中的必需输入/输出和认证要求来确保正确性。
快速开始
- 1. 从 fal 模型 API 文档中确定目标模型 ID。
- 收集用户输入。
- 文本转图像:prompt(提示词)、可选的 negative_prompt(负面提示词)、尺寸/宽高比、步数、种子、安全选项。
- 图像转图像:源图像 URL、强度/降噪参数,以及上述提示词和选项。
- 3. 选择调用方式。
- 如果用户偏好 SDK:提供 Python 和/或 JavaScript 示例。
- 如果用户偏好 REST:提供 curl/HTTP 示例。
- 4. 执行请求并从响应中返回图像 URL。
工作流程:文本转图像
- 1. 解析模型 ID 和模式。
- 打开 fal 模型 API 文档,确认确切的输入字段和输出格式。
- 2. 验证输入。
- 确保提示词非空,且模型支持所选的尺寸/宽高比设置。
- 3. 构建请求。
- SDK:使用 input 对象调用 SDK 的 run/submit 方法。
- REST:使用与模式匹配的 JSON 主体调用模型端点。
- 4. 执行并解析输出。
- 从模型定义的响应字段中提取图像 URL。
- 5. 返回 URL。
- 提供清晰的 URL 列表,并注明用户要求的任何元数据(种子、尺寸等)。
工作流程:图像转图像
- 1. 解析模型 ID 和模式。
- 验证输入。
- 确保源图像可通过 URL 访问(或已转换为所需格式)。
- 从文档中确认任何强度/降噪参数的范围限制。
- 3. 构建请求。
- 根据模型要求包含源图像、提示词和其他选项。
- 4. 执行并解析输出。
- 从模型定义的响应字段中提取图像 URL。
- 5. 返回 URL。
SDK 与 REST 指南
- - 优先使用 SDK 以获得更简单的认证和重试机制。
- 当用户需要原始 HTTP 示例,或在没有 SDK 支持的环境中运行时,优先使用 REST。
- 切勿硬编码 API 密钥。按照文档设置所需的环境变量或请求头名称。
最小示例(从文档中填充)
仅作为模板使用。查阅文档后替换占位符。
Python(SDK)
python
伪代码:根据文档替换为确切的 fal SDK 导入和调用模式
import os
from fal import client # 或当前 SDK 的导入方式
MODEL_ID = <模型ID-来自文档>
input_data = {
prompt: 一只红狐狸的电影级照片,
# image_url: https://... # 用于图像转图像
# negative_prompt: ...,
# width: 1024,
# height: 1024,
}
result = client.run(MODELID, input=inputdata)
urls = extract_urls(result)
JavaScript(SDK)
javascript
// 伪代码:根据文档替换为确切的 fal SDK 导入和调用模式
// import { client } from @fal-ai/client;
const MODEL_ID = <模型ID-来自文档>;
const input = {
prompt: 一只红狐狸的电影级照片,
// image_url: https://... // 用于图像转图像
};
// const result = await client.run(MODEL_ID, { input });
// const urls = extractUrls(result);
REST(curl)
bash
伪代码:根据文档替换端点、请求头和负载模式
curl -X POST https://
/<模型端点> \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
prompt: 一只红狐狸的电影级照片
}
资源
- - references/fal-model-api-checklist.md:收集输入和验证响应的检查清单。
- references/fal-model-examples.md:文本转图像、图像转图像和 REST 使用的示例模板。