fotor-skills
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesefotor-skills
fotor-skills
Async-first Python SDK for the Fotor OpenAPI. No MCP -- just an API key.
Use as the skill's bootstrap layer. Prefer a skill-local Python 3.12 environment and run bundled scripts from that local environment instead of the system Python.
uv面向Fotor OpenAPI的异步优先Python SDK,无需MCP,仅需一个API密钥即可使用。
使用作为该Skill的启动层,优先使用Skill本地的Python 3.12环境,从本地环境运行捆绑的脚本,而非使用系统Python。
uvSetup
安装配置
Keep setup lightweight and local to the skill directory.
Install first if it is missing:
uvbash
undefined保持安装流程轻量,所有环境都部署在Skill目录下。
如果没有安装请先执行安装:
uvbash
undefinedmacOS / Linux
macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows (PowerShell)
Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Typical first-run setup:
```bash
uv python install 3.12
uv venv --python 3.12 .venv
./.venv/bin/python scripts/ensure_sdk.pySetup rules:
- Prefer a local Python 3.12 environment in the skill directory.
- Use to prepare Python 3.12 and create
uvwhen the local environment is missing..venv - Run bundled scripts from the local skill environment, not the system Python.
- Ensure is set. If key setup is missing and the user is not technical, read
FOTOR_OPENAPI_KEYand prefer the localreferences/configure-fotor-openapi-key.mdhappy path..env
Current default interpreter paths:
- POSIX:
./.venv/bin/python - Windows:
.venv\\Scripts\\python.exe
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
典型的首次运行配置流程:
```bash
uv python install 3.12
uv venv --python 3.12 .venv
./.venv/bin/python scripts/ensure_sdk.py配置规则:
- 优先使用Skill目录下的本地Python 3.12环境
- 本地环境缺失时,使用准备Python 3.12并创建
uv虚拟环境.venv - 从Skill本地环境运行捆绑脚本,不要使用系统Python
- 确保已配置。如果缺少密钥配置且用户不了解技术相关操作,请阅读
FOTOR_OPENAPI_KEY,优先使用本地references/configure-fotor-openapi-key.md文件的配置方案.env
当前默认解释器路径:
- POSIX:
./.venv/bin/python - Windows:
.venv\\Scripts\\python.exe
Interaction Rules
交互规则
- Speak in user-task language first. Do not lead with SDK, scripts, JSON, model IDs, or parameter tables unless they are needed to unblock the task or the user explicitly asks.
- Ask for only one missing blocker at a time.
- Once the minimum required information is present, execute immediately. Do not send vague transition messages like "I’m starting now" unless execution has actually started and a result or clear in-progress status will follow.
- If execution will take noticeable time, say that the task is running and give a short expectation such as "usually takes a few seconds to a few dozen seconds; I’ll send the result when it’s ready."
- If credentials are missing, resolve that blocker quickly and then return to the original task instead of turning the conversation into a long setup lesson.
- When the local skill environment is missing, prepare it with before installing dependencies or executing the task. Avoid installing into the system Python unless the user explicitly asks.
uv - Choose the model and default parameters internally unless the user explicitly requests a specific model or technical control.
- Return the result as soon as it is ready. Do not make the user ask follow-up questions like "where is the image?"
- If an update reminder is available, keep it to one short non-blocking sentence and continue the current task.
- 优先使用用户易懂的任务相关话术沟通,除非用户明确要求或者为了推进任务必须提及,否则不要主动提到SDK、脚本、JSON、模型ID、参数表等技术内容
- 每次仅询问一个缺失的必要信息
- 收集到最少必要信息后立即执行任务,除非任务已经实际启动且后续会返回结果或明确的进度状态,否则不要发送「我现在开始处理」这类模糊的过渡消息
- 如果任务执行需要较长时间,请告知用户任务正在运行,并给出预期耗时,例如「通常需要几秒到几十秒不等,结果准备好后我会立即发送给你」
- 如果缺少凭证,请优先快速解决凭证问题后回到原任务,不要把对话变成冗长的配置教程
- 如果本地Skill环境缺失,请先使用准备环境,再安装依赖或执行任务,除非用户明确要求,否则不要安装到系统Python中
uv - 内部自动选择模型和默认参数,除非用户明确要求指定模型或进行技术参数调整
- 结果准备就绪后立即返回,不要让用户追问「图片在哪里?」这类问题
- 如果有更新提醒,仅用一句简短的非阻塞语句告知,然后继续当前任务
Scripts
脚本说明
scripts/ensure_sdk.py
scripts/ensure_sdk.pyscripts/ensure_sdk.py
scripts/ensure_sdk.pyCross-platform (Windows / macOS / Linux) script to install or upgrade to the latest PyPI release with . Run before every task.
fotor-sdkuv pip install --python <interpreter>- No args — install or upgrade to the latest PyPI release
- — same behavior, kept as an explicit alias
--upgrade
跨平台(Windows/macOS/Linux)脚本,用于通过将安装或升级到最新的PyPI版本,每次执行任务前都需要运行
uv pip install --python <interpreter>fotor-sdk- 无参数 — 安装或升级到最新的PyPI版本
- — 功能和无参数一致,作为显式别名保留
--upgrade
scripts/run_task.py
scripts/run_task.pyscripts/run_task.py
scripts/run_task.pyExecute one or more Fotor tasks from JSON. Handles client init, polling, and progress.
Single task:
bash
echo '{"task_type":"text2image","params":{"prompt":"A cat","model_id":"seedream-4-5-251128"}}' \
| ./.venv/bin/python scripts/run_task.pyBatch (array):
bash
echo '[
{"task_type":"text2image","params":{"prompt":"A cat","model_id":"seedream-4-5-251128"},"tag":"cat"},
{"task_type":"text2video","params":{"prompt":"Sunset","model_id":"kling-v3","duration":5},"tag":"sunset"}
]' | ./.venv/bin/python scripts/run_task.py --concurrency 5Options: , (default 5), (default 2.0), (default 1200).
--input FILE--concurrency N--poll-interval S--timeout SOutput: JSON with , , , , , , , .
task_idstatussuccessresult_urlerrorelapsed_secondscreditsIncrementtagAutomatic fallback:
- If a task fails on its primary model and the current matches a built-in fallback mapping,
task_type + model_idautomatically retries once with the fallback model.run_task.py - The output includes ,
fallback_used, andoriginal_model_id.fallback_model_id
从JSON输入执行一个或多个Fotor任务,处理客户端初始化、轮询和进度查询
单个任务:
bash
echo '{"task_type":"text2image","params":{"prompt":"A cat","model_id":"seedream-4-5-251128"}}' \
| ./.venv/bin/python scripts/run_task.py批量任务(数组输入):
bash
echo '[
{"task_type":"text2image","params":{"prompt":"A cat","model_id":"seedream-4-5-251128"},"tag":"cat"},
{"task_type":"text2video","params":{"prompt":"Sunset","model_id":"kling-v3","duration":5},"tag":"sunset"}
]' | ./.venv/bin/python scripts/run_task.py --concurrency 5可选参数: 、(默认5)、(默认2.0)、(默认1200)
--input FILE--concurrency N--poll-interval S--timeout S输出: 包含、、、、、、、字段的JSON
task_idstatussuccessresult_urlerrorelapsed_secondscreditsIncrementtag自动降级机制:
- 如果任务在主模型上执行失败,且当前的匹配内置的降级映射,
task_type + model_id会自动使用降级模型重试一次run_task.py - 输出会包含、
fallback_used和original_model_id字段fallback_model_id
scripts/upload_image.py
scripts/upload_image.pyscripts/upload_image.py
scripts/upload_image.pyUpload a local image file through Fotor's signed upload flow and return a reusable image URL.
bash
./.venv/bin/python scripts/upload_image.py ./input.jpg --task-type image2imageThe script:
- Calls with the mapped upload
/v1/upload/signandtypesuffix - Uploads the local file to the signed target
- Prints JSON containing and
file_urlupload_url
Use as the , , , or an item inside for image-based tasks.
file_urlimage_urlstart_image_urlend_image_urlimage_urlsSupported task-to-upload mapping:
- ->
image2imageimg2img - ->
image_upscaleimg_upscale - ->
background_removebg_remove - ->
single_image2videoimg2video - ->
start_end_frame2videoimg2video - ->
multiple_image2videoimg2video
通过Fotor的签名上传流程上传本地图片文件,返回可复用的图片URL
bash
./.venv/bin/python scripts/upload_image.py ./input.jpg --task-type image2image该脚本会:
- 调用接口,传入映射后的上传
/v1/upload/sign和typesuffix - 将本地文件上传到签名目标地址
- 打印包含和
file_url的JSONupload_url
可将作为、、,或者图像类任务的数组中的元素使用
file_urlimage_urlstart_image_urlend_image_urlimage_urls支持的任务类型与上传类型映射:
- ->
image2imageimg2img - ->
image_upscaleimg_upscale - ->
background_removebg_remove - ->
single_image2videoimg2video - ->
start_end_frame2videoimg2video - ->
multiple_image2videoimg2video
scripts/check_skill_update.py
scripts/check_skill_update.pyscripts/check_skill_update.py
scripts/check_skill_update.pyCheck whether the installed skill has a newer version available for the current install source.
bash
./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24For development/testing when install-source metadata is unavailable:
bash
./.venv/bin/python scripts/check_skill_update.py --install-source skills-github --slug fotor-skills --current-version 1.0.0 --github-source fotor-ai/fotor-skills --mark-notified --check-interval-hours 24The script:
- Detects the install source first: or
clawhubskills-github - For , reads installed
clawhuband fetches the latest version via_meta.jsonclawhub inspect <slug> --json - For , reads local
skills-githubfrontmatterSKILL.md, finds the GitHub source, and fetches the remotemetadata.versionversion plusSKILL.mdhighlights when availableCHANGELOG.md - Prints JSON with ,
install_source,current_version,latest_version, andupdate_availableshould_notify - Stores the last-notified version in a local state file when is used
--mark-notified - Caches the last successful version check and supports a minimum recheck interval via (default 24)
--check-interval-hours - Includes so the reminder can mention the main highlights without dumping the full changelog
changelog_preview - Supports development/testing overrides such as ,
--install-source,--slug, and--current-version--github-source
检查当前安装的Skill是否有对应安装源的可用新版本
bash
./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24开发/测试场景下如果缺少安装源元数据,可以使用以下命令:
bash
./.venv/bin/python scripts/check_skill_update.py --install-source skills-github --slug fotor-skills --current-version 1.0.0 --github-source fotor-ai/fotor-skills --mark-notified --check-interval-hours 24该脚本会:
- 首先检测安装源:或
clawhubskills-github - 对于源,读取已安装的
clawhub,通过_meta.json拉取最新版本clawhub inspect <slug> --json - 对于源,读取本地
skills-github前言中的SKILL.md,找到GitHub源,拉取远程metadata.version的版本以及可用的SKILL.md亮点更新CHANGELOG.md - 打印包含、
install_source、current_version、latest_version、update_available的JSONshould_notify - 使用参数时,会将上次通知的版本存储在本地状态文件中
--mark-notified - 缓存上次成功的版本检查结果,通过参数支持最小重查间隔(默认24小时)
--check-interval-hours - 包含字段,方便提醒时仅展示主要更新亮点,无需输出完整更新日志
changelog_preview - 支持开发/测试参数覆盖,例如、
--install-source、--slug、--current-version--github-source
Reference Files
参考文件
Only read the reference files that match the current need. Do not load all of them by default.
仅读取与当前需求匹配的参考文件,默认不要加载全部文件
Task Execution References
任务执行参考
Read these when choosing a model, validating parameters, or mapping an ambiguous user request to a recommended workflow:
- -- image model IDs, T2I/I2I capabilities, per-model parameter constraints (resolution, ratios, input limits, max refs)
references/image_models.md - -- video model IDs, T2V/I2V/SE/MI capabilities, per-model parameter constraints (duration, resolution, ratios, input limits, audio)
references/video_models.md - -- full function signatures and parameter tables for all 8 task types
references/parameter_reference.md - -- scenario-to-model mapping for image generation (T2I, I2I, utilities); read when user intent is ambiguous
references/image_scenarios.md - -- scenario-to-model mapping for video generation (T2V, I2V, SE, MI); read when user intent is ambiguous
references/video_scenarios.md
在选择模型、验证参数、或者将模糊的用户请求映射为推荐工作流时阅读这些文件:
- — 图像模型ID、T2I/I2I能力、各模型参数约束(分辨率、比例、输入限制、最大参考数)
references/image_models.md - — 视频模型ID、T2V/I2V/SE/MI能力、各模型参数约束(时长、分辨率、比例、输入限制、音频)
references/video_models.md - — 全部8种任务类型的完整函数签名和参数表
references/parameter_reference.md - — 图像生成(T2I、I2I、工具类)的场景到模型映射,用户意图模糊时阅读
references/image_scenarios.md - — 视频生成(T2V、I2V、SE、MI)的场景到模型映射,用户意图模糊时阅读
references/video_scenarios.md
Operational References
运维参考
Read these only when the user asks about installation, upgrade, workspace layout, or credential setup. Do not read them for normal image/video task execution.
- -- how to install or upgrade
references/install-or-upgrade.mdfor both ClawHub andfotor-skills, and how to phrase a concise non-pushy upgrade remindernpx skills - -- how to set, persist, verify, and safely handle
references/configure-fotor-openapi-key.mdFOTOR_OPENAPI_KEY
仅当用户询问安装、升级、工作区布局或凭证配置时阅读这些文件,正常执行图像/视频任务时不需要读取:
- — 如何为ClawHub和
references/install-or-upgrade.md安装或升级npx skills,以及如何撰写简洁不打扰的升级提醒话术fotor-skills - — 如何设置、持久化、验证和安全处理
references/configure-fotor-openapi-key.mdFOTOR_OPENAPI_KEY
Workflow
工作流
- If is missing, install it first using the platform-appropriate installer shown in Setup.
uv - If Python 3.12 is not already available to , run
uv.uv python install 3.12 - If is missing, create it with
.venv.uv venv --python 3.12 .venv - Run before every task to install or upgrade the latest
./.venv/bin/python scripts/ensure_sdk.pywithfotor-sdk.uv - After is ready and
.venvcompletes, silently runensure_sdk.py. Do not inspect the state file manually. Only if it reports./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24, readshould_notify: trueand send one short non-blocking update reminder. If the check fails or times out, ignore it and continue without mentioning the failure.references/install-or-upgrade.md - Verify is set.
FOTOR_OPENAPI_KEY - For image-based tasks that start from a local file, first run and keep the returned
./.venv/bin/python scripts/upload_image.py <local-file> --task-type <task-type>.file_url - Read the appropriate model reference to choose . Each model's per-model spec section lists supported resolutions, aspect ratios, duration, input constraints, and max reference images.
model_id - If user intent is ambiguous (no specific model requested), consult the scenario files (/
image_scenarios.md) for recommended model + params.video_scenarios.md - Validate parameters against the chosen model's spec before calling -- check resolution, aspect ratio, duration, and multi-image limits.
- Quick path -- pipe JSON into (works for both single and batch).
./.venv/bin/python scripts/run_task.py - Custom path -- write inline Python using the SDK directly (see examples below), still preferring the local interpreter.
.venv - Check in output. Chain
result_urlif higher resolution needed.image_upscale
If the user asks to check account credits or remaining credits, use the SDK client directly instead of .
run_task.pyBuilt-in automatic fallback mappings:
- :
text2image->gemini-3.1-flash-image-previewseedream-5-0-260128 - :
image2image->gemini-3.1-flash-image-previewseedream-5-0-260128 - :
text2video->doubao-seedance-1-5-prokling-v3 - :
single_image2video->doubao-seedance-1-5-prokling-v3 - :
start_end_frame2video->kling-video-o1viduq2-turbo - :
multiple_image2video->kling-v3-omnikling-video-o1
- 如果缺失,先使用安装配置章节中对应平台的安装命令安装
uv - 如果没有可用的Python 3.12,运行
uvuv python install 3.12 - 如果缺失,使用
.venv创建虚拟环境uv venv --python 3.12 .venv - 每次执行任务前都要运行,通过
./.venv/bin/python scripts/ensure_sdk.py安装或升级到最新版uvfotor-sdk - 准备完成且
.venv执行结束后,静默运行ensure_sdk.py。不要手动检查状态文件,仅当返回./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24时,阅读should_notify: true并发送一条简短的非阻塞更新提醒。如果检查失败或超时,直接忽略,不要提及失败情况继续执行任务references/install-or-upgrade.md - 验证已配置
FOTOR_OPENAPI_KEY - 对于需要从本地文件启动的图像类任务,首先运行,保存返回的
./.venv/bin/python scripts/upload_image.py <本地文件路径> --task-type <任务类型>file_url - 阅读对应的模型参考文档选择,每个模型的规格说明中列出了支持的分辨率、宽高比、时长、输入约束和最大参考图像数量
model_id - 如果用户意图模糊(没有指定模型),参考场景文件(/
image_scenarios.md)选择推荐的模型和参数video_scenarios.md - 调用接口前验证参数是否符合所选模型的规格,检查分辨率、宽高比、时长和多图限制
- 快速路径 — 将JSON输入管道传入(支持单任务和批量任务)
./.venv/bin/python scripts/run_task.py - 自定义路径 — 直接使用SDK编写内嵌Python代码(参考下方示例),仍然优先使用本地解释器
.venv - 检查输出中的,如果需要更高分辨率,可以链式调用
result_url任务image_upscale
如果用户要求查询账户额度或剩余额度,请直接使用SDK客户端,不要使用
run_task.py内置自动降级映射:
- :
text2image->gemini-3.1-flash-image-previewseedream-5-0-260128 - :
image2image->gemini-3.1-flash-image-previewseedream-5-0-260128 - :
text2video->doubao-seedance-1-5-prokling-v3 - :
single_image2video->doubao-seedance-1-5-prokling-v3 - :
start_end_frame2video->kling-video-o1viduq2-turbo - :
multiple_image2video->kling-v3-omnikling-video-o1
Available Task Types
支持的任务类型
| task_type | Function | Required Params |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
For full parameter details (defaults, , ), read .
on_poll**extrareferences/parameter_reference.md| task_type | 对应函数 | 必选参数 |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
完整参数详情(默认值、、)请阅读
on_poll**extrareferences/parameter_reference.mdCredit Lookup
额度查询
For account credit checks such as total credits or remaining credits, use the SDK client directly instead of .
run_task.pypython
import os
from fotor_sdk import FotorClient
client = FotorClient(
api_key=os.environ["FOTOR_OPENAPI_KEY"],
endpoint=os.environ.get("FOTOR_OPENAPI_ENDPOINT", "https://api.fotor.com"),
)
credits = client.get_credits_sync()
print("credits:", credits)Returns a dict like:
python
{"businessId": "", "total": 2000, "remaining": 1973}如果需要查询账户总额度、剩余额度等信息,请直接使用SDK客户端,不要使用
run_task.pypython
import os
from fotor_sdk import FotorClient
client = FotorClient(
api_key=os.environ["FOTOR_OPENAPI_KEY"],
endpoint=os.environ.get("FOTOR_OPENAPI_ENDPOINT", "https://api.fotor.com"),
)
credits = client.get_credits_sync()
print("credits:", credits)返回的字典格式如下:
python
{"businessId": "", "total": 2000, "remaining": 1973}Inline Python Examples
内嵌Python示例
When is insufficient (custom logic, chaining, progress callbacks):
scripts/run_task.py当无法满足需求时(自定义逻辑、任务链式调用、进度回调)可以使用以下方式:
scripts/run_task.pyClient Init
客户端初始化
python
import os
from fotor_sdk import FotorClient
client = FotorClient(api_key=os.environ["FOTOR_OPENAPI_KEY"])python
import os
from fotor_sdk import FotorClient
client = FotorClient(api_key=os.environ["FOTOR_OPENAPI_KEY"])Single Task
单个任务
python
from fotor_sdk import text2image
result = await text2image(client, prompt="A diamond kitten", model_id="seedream-4-5-251128")
print(result.result_url)python
from fotor_sdk import text2image
result = await text2image(client, prompt="A diamond kitten", model_id="seedream-4-5-251128")
print(result.result_url)Batch with TaskRunner
使用TaskRunner执行批量任务
python
from fotor_sdk import TaskRunner, TaskSpec
runner = TaskRunner(client, max_concurrent=5)
specs = [
TaskSpec("text2image", {"prompt": "A cat", "model_id": "seedream-4-5-251128"}, tag="cat"),
TaskSpec("text2video", {"prompt": "Sunset", "model_id": "kling-v3", "duration": 5}, tag="sunset"),
]
results = await runner.run(specs)python
from fotor_sdk import TaskRunner, TaskSpec
runner = TaskRunner(client, max_concurrent=5)
specs = [
TaskSpec("text2image", {"prompt": "A cat", "model_id": "seedream-4-5-251128"}, tag="cat"),
TaskSpec("text2video", {"prompt": "Sunset", "model_id": "kling-v3", "duration": 5}, tag="sunset"),
]
results = await runner.run(specs)Video with Audio
带音频的视频生成
python
from fotor_sdk import text2video
result = await text2video(client, prompt="Jazz band", model_id="kling-v3",
audio_enable=True, audio_prompt="Smooth jazz")python
from fotor_sdk import text2video
result = await text2video(client, prompt="Jazz band", model_id="kling-v3",
audio_enable=True, audio_prompt="Smooth jazz")TaskResult
TaskResult字段说明
python
result.success # bool: True when COMPLETED with result_url
result.result_url # str | None
result.status # TaskStatus: COMPLETED / FAILED / TIMEOUT / IN_PROGRESS / CANCELLED
result.error # str | None (e.g. "NSFW_CONTENT")
result.elapsed_seconds # float
result.creditsIncrement # int | float: credits consumed by this task
result.metadata # dict (includes "tag" from TaskRunner)python
result.success # bool: 任务完成且有result_url时为True
result.result_url # str | None
result.status # TaskStatus: COMPLETED / FAILED / TIMEOUT / IN_PROGRESS / CANCELLED
result.error # str | None (例如 "NSFW_CONTENT")
result.elapsed_seconds # float
result.creditsIncrement # int | float: 该任务消耗的额度
result.metadata # dict (包含TaskRunner传入的 "tag")Error Handling
错误处理
- Single task: catch (has
FotorAPIErrorattribute)..code - Batch: check per item; runner never raises on individual failures.
result.success - NSFW: appears as in TaskResult.
error="NSFW_CONTENT"
For troubleshooting, enable SDK debug logging: .
logging.getLogger("fotor_sdk").setLevel(logging.DEBUG)- 单个任务: 捕获(包含
FotorAPIError属性).code - 批量任务: 逐个检查,TaskRunner不会因为单个任务失败抛出异常
result.success - NSFW内容: 会在TaskResult中返回
error="NSFW_CONTENT"
如需排查问题,可以开启SDK调试日志:
logging.getLogger("fotor_sdk").setLevel(logging.DEBUG)