fotor-skills
Async-first Python SDK for the Fotor OpenAPI. No MCP -- just an API key.
Use uv 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.
Setup
Keep setup lightweight and local to the skill directory.
Install uv first if it is missing:
CODEBLOCK0
Typical first-run setup:
CODEBLOCK1
Setup rules:
- 1. Prefer a local Python 3.12 environment in the skill directory.
- Use
uv to prepare Python 3.12 and create .venv when the local environment is missing. - Run bundled scripts from the local skill environment, not the system Python.
- Ensure
FOTOR_OPENAPI_KEY is set. If the user asks where to get a key, wants the official fotor-skills homepage during setup, or needs a key + homepage walkthrough, read references/get_api_key.md first.
Current default interpreter paths:
- - POSIX: INLINECODE7
- Windows: INLINECODE8
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
uv before installing dependencies or executing the task. Avoid installing into the system Python unless the user explicitly asks. - 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 the user asks how to recharge, buy credits, top up, or purchase tokens, use
references/credits-and-recharge.md and follow its recharge guidance flow. - If a task fails because credits are insufficient, do not stop at the raw error. Use
references/credits-and-recharge.md to explain the failure and provide recharge guidance. - If an update reminder is available, keep it to one short non-blocking sentence and continue the current task.
Scripts
scripts/ensure_sdk.py
Cross-platform (Windows / macOS / Linux) script to install or upgrade fotor-sdk to the latest PyPI release with uv pip install --python <interpreter>. Run before every task.
- - No args — install or upgrade to the latest PyPI release
--upgrade — same behavior, kept as an explicit alias
scripts/run_task.py
Execute one or more Fotor tasks from JSON. Handles client init, polling, and progress.
Single task:
CODEBLOCK2
Batch (array):
CODEBLOCK3
Options: --input FILE, --concurrency N (default 5), --poll-interval S (default 2.0), --timeout S (default 1200).
Output: JSON with task_id, status, success, result_url, error, elapsed_seconds, creditsIncrement, tag.
Automatic fallback:
- - If a task fails on its primary model and the current
task_type + model_id matches a built-in fallback mapping, run_task.py automatically retries once with the fallback model. - If the failure is insufficient credits (
code=510 / No enough credits), run_task.py returns the failure immediately and does not retry on a fallback model. - The output includes
fallback_used, original_model_id, and fallback_model_id.
scripts/upload_image.py
Upload a local image file through Fotor's signed upload flow and return a reusable image URL.
CODEBLOCK4
The script:
- - Calls
/v1/upload/sign with the mapped upload type and INLINECODE40 - Uploads the local file to the signed target
- Prints JSON containing
file_url and INLINECODE42
Use file_url as the image_url, start_image_url, end_image_url, or an item inside image_urls for image-based tasks.
Supported task-to-upload mapping:
- -
image2image -> INLINECODE49 - INLINECODE50 -> INLINECODE51
- INLINECODE52 -> INLINECODE53
- INLINECODE54 -> INLINECODE55
- INLINECODE56 -> INLINECODE57
- INLINECODE58 -> INLINECODE59
scripts/check_skill_update.py
Check whether the installed skill has a newer version available for the current install source.
CODEBLOCK5
For development/testing when install-source metadata is unavailable:
CODEBLOCK6
The script:
- - Detects the install source first:
clawhub or INLINECODE62 - For
clawhub, reads installed _meta.json and fetches the latest version via INLINECODE65 - For
skills-github, reads local SKILL.md frontmatter top-level version field, falls back to legacy metadata.version, finds the GitHub source, and fetches the remote SKILL.md version plus CHANGELOG.md highlights when available - Prints JSON with
install_source, current_version, latest_version, update_available, and INLINECODE76 - Stores the last-notified version in a local state file when
--mark-notified is used - Caches the last successful version check and supports a minimum recheck interval via
--check-interval-hours (default 24) - Includes
changelog_preview so the reminder can mention the main highlights without dumping the full changelog - Supports development/testing overrides such as
--install-source, --slug, --current-version, and INLINECODE83
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:
- -
references/image_models.md -- image model IDs, T2I/I2I capabilities, per-model parameter constraints (resolution, ratios, input limits, max refs) - INLINECODE85 -- video model IDs, T2V/I2V/SE/MI capabilities, per-model parameter constraints (duration, resolution, ratios, input limits, audio)
- INLINECODE86 -- full function signatures and parameter tables for all 8 task types
- INLINECODE87 -- scenario-to-model mapping for image generation (T2I, I2I, utilities); read when user intent is ambiguous
- INLINECODE88 -- scenario-to-model mapping for video generation (T2V, I2V, SE, MI); read when user intent is ambiguous
Operational References
Read these only when the user asks about installation, upgrade, workspace layout, API key acquisition, or the official fotor-skills homepage. Do not read them for normal image/video task execution.
- -
references/credits-and-recharge.md -- credit lookup, payment links, recharge guidance, and insufficient-credit handling - INLINECODE91 -- guide for giving the official
fotor-skills homepage, sending users to the API-key dashboard entry, and configuring INLINECODE93 - INLINECODE94 -- how to install or upgrade
fotor-skills for both ClawHub and npx skills, and how to phrase a concise non-pushy upgrade reminder
Workflow
- 1. If
uv is missing, install it first using the platform-appropriate installer shown in Setup. - If Python 3.12 is not already available to
uv, run uv python install 3.12. - If
.venv is missing, create it with uv venv --python 3.12 .venv. - Run
./.venv/bin/python scripts/ensure_sdk.py before every task to install or upgrade the latest fotor-sdk with uv. - After
.venv is ready and ensure_sdk.py completes, silently run ./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24. Do not inspect the state file manually. Only if it reports should_notify: true, read references/install-or-upgrade.md and send one short non-blocking update reminder. If the check fails or times out, ignore it and continue without mentioning the failure. - If the user asks how to get an API key or wants the official
fotor-skills homepage during setup, read references/get_api_key.md and include both links before expanding into lower-level setup details. - Verify
FOTOR_OPENAPI_KEY is set. - If the user asks about account credits, recharge, buying credits, or payment links, read
references/credits-and-recharge.md, then use the appropriate balance or payment-links flow from that reference. - For image-based tasks that start from a local file, first run
./.venv/bin/python scripts/upload_image.py <local-file> --task-type <task-type> and keep the returned file_url. - Read the appropriate model reference to choose
model_id. Each model's per-model spec section lists supported resolutions, aspect ratios, duration, input constraints, and max reference images. - If user intent is ambiguous (no specific model requested), consult the scenario files (
image_scenarios.md / video_scenarios.md) for recommended model + params. - Validate parameters against the chosen model's spec before calling -- check resolution, aspect ratio, duration, and multi-image limits.
- Quick path -- pipe JSON into
./.venv/bin/python scripts/run_task.py (works for both single and batch). - Custom path -- write inline Python using the SDK directly (see examples below), still preferring the local
.venv interpreter. - Check
result_url in output. Chain image_upscale if higher resolution needed.
If the user asks to check account credits or remaining credits, read references/credits-and-recharge.md and use the SDK client flow described there instead of run_task.py.
Built-in automatic fallback mappings:
- -
text2image: gemini-3.1-flash-image-preview -> INLINECODE127 - INLINECODE128 :
gemini-3.1-flash-image-preview -> INLINECODE130 - INLINECODE131 :
doubao-seedance-1-5-pro -> INLINECODE133 - INLINECODE134 :
doubao-seedance-1-5-pro -> INLINECODE136 - INLINECODE137 :
kling-video-o1 -> INLINECODE139 - INLINECODE140 :
kling-v3-omni -> INLINECODE142
Available Task Types
| task_type | Function | Required Params |
|---|
| INLINECODE143 | INLINECODE144 | INLINECODE145 , INLINECODE146 |
| INLINECODE147 |
image2image() |
prompt,
model_id,
image_urls |
|
image_upscale |
image_upscale() |
image_url |
|
background_remove |
background_remove() |
image_url |
|
text2video |
text2video() |
prompt,
model_id |
|
single_image2video |
single_image2video() |
prompt,
model_id,
image_url |
|
start_end_frame2video |
start_end_frame2video() |
prompt,
model_id,
start_image_url,
end_image_url |
|
multiple_image2video |
multiple_image2video() |
prompt,
model_id,
image_urls (≥2) |
For full parameter details (defaults, on_poll, **extra), read references/parameter_reference.md.
Credits and Recharge
For any balance lookup, recharge guidance, or insufficient-credit case, read references/credits-and-recharge.md.
Keep SKILL.md focused on routing:
- - Use the credits reference when the user asks about remaining balance, total credits, recharge, top-up, or payment links.
- Use the same reference when a task fails with
code=510 or No enough credits. - Keep detailed API examples, field meanings, and user-facing recharge wording in the reference instead of expanding this main skill file.
Inline Python Examples
When scripts/run_task.py is insufficient (custom logic, chaining, progress callbacks):
Client Init
CODEBLOCK7
Single Task
CODEBLOCK8
Batch with TaskRunner
CODEBLOCK9
Video with Audio
CODEBLOCK10
TaskResult
CODEBLOCK11
Error Handling
- - Single task: catch
FotorAPIError (has .code attribute). - Batch: check
result.success per item; runner never raises on individual failures. - NSFW: appears as
error="NSFW_CONTENT" in TaskResult. - Insufficient credits: if
result.error, exception text, or a combined fallback error contains code=510 or No enough credits, treat it as a recharge case. Tell the user credits are insufficient, then fetch and present payment links.
For troubleshooting, enable SDK debug logging: logging.getLogger("fotor_sdk").setLevel(logging.DEBUG).
fotor-skills
Fotor OpenAPI 的异步优先 Python SDK。无需 MCP——仅需一个 API 密钥。
使用 uv 作为技能的引导层。优先使用技能本地的 Python 3.12 环境,并从该本地环境运行捆绑脚本,而非系统 Python。
设置
保持设置轻量且局限于技能目录。
如果缺少 uv,请先安装:
bash
macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows (PowerShell)
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
设置规则:
- 1. 优先在技能目录中使用本地 Python 3.12 环境。
- 当本地环境缺失时,使用 uv 准备 Python 3.12 并创建 .venv。
- 从本地技能环境运行捆绑脚本,而非系统 Python。
- 确保设置了 FOTOROPENAPIKEY。如果用户询问如何获取密钥、在设置期间需要官方 fotor-skills 主页,或需要密钥及主页的引导,请先阅读 references/getapikey.md。
当前默认解释器路径:
- - POSIX:./.venv/bin/python
- Windows:.venv\\Scripts\\python.exe
交互规则
- - 首先使用用户任务语言进行交流。除非需要解除任务阻塞或用户明确询问,否则不要先提及 SDK、脚本、JSON、模型 ID 或参数表。
- 每次只询问一个缺失的阻塞项。
- 一旦获得最低限度的必要信息,立即执行。除非执行已实际开始并且将随后提供结果或明确的进行中状态,否则不要发送模糊的过渡消息,如我现在开始。
- 如果执行需要明显的时间,请说明任务正在运行,并给出简短预期,例如通常需要几秒到几十秒;完成后我会发送结果。
- 如果凭据缺失,快速解决该阻塞项,然后返回原始任务,而不是将对话变成冗长的设置教程。
- 当本地技能环境缺失时,在安装依赖项或执行任务之前使用 uv 准备它。除非用户明确要求,否则避免安装到系统 Python。
- 除非用户明确请求特定模型或技术控制,否则内部选择模型和默认参数。
- 一旦结果准备好,立即返回。不要让用户追问诸如图片在哪里?之类的问题。
- 如果用户询问如何充值、购买积分、充值或购买令牌,请使用 references/credits-and-recharge.md 并遵循其中的充值引导流程。
- 如果任务因积分不足而失败,不要停留在原始错误上。使用 references/credits-and-recharge.md 解释失败原因并提供充值引导。
- 如果有更新提醒可用,将其保持为一句简短的非阻塞性语句,并继续当前任务。
脚本
scripts/ensure_sdk.py
跨平台(Windows / macOS / Linux)脚本,使用 uv pip install --python 安装或升级 fotor-sdk 至最新的 PyPI 版本。在每个任务前运行。
- - 无参数 — 安装或升级至最新的 PyPI 版本
- --upgrade — 行为相同,作为显式别名保留
scripts/run_task.py
从 JSON 执行一个或多个 Fotor 任务。处理客户端初始化、轮询和进度。
单个任务:
bash
echo {tasktype:text2image,params:{prompt:一只猫,modelid:seedream-4-5-251128}} \
| ./.venv/bin/python scripts/run_task.py
批量(数组):
bash
echo [
{tasktype:text2image,params:{prompt:一只猫,modelid:seedream-4-5-251128},tag:cat},
{tasktype:text2video,params:{prompt:日落,modelid:kling-v3,duration:5},tag:sunset}
] | ./.venv/bin/python scripts/run_task.py --concurrency 5
选项: --input FILE、--concurrency N(默认 5)、--poll-interval S(默认 2.0)、--timeout S(默认 1200)。
输出: 包含 taskid、status、success、resulturl、error、elapsed_seconds、creditsIncrement、tag 的 JSON。
自动回退:
- - 如果任务在其主模型上失败,且当前的 tasktype + modelid 匹配内置的回退映射,runtask.py 会自动使用回退模型重试一次。
- 如果失败原因是积分不足(code=510 / No enough credits),runtask.py 会立即返回失败,不会在回退模型上重试。
- 输出中包含 fallbackused、originalmodelid 和 fallbackmodel_id。
scripts/upload_image.py
通过 Fotor 的签名上传流程上传本地图像文件,并返回可重复使用的图像 URL。
bash
./.venv/bin/python scripts/upload_image.py ./input.jpg --task-type image2image
该脚本:
- - 使用映射的上传 type 和 suffix 调用 /v1/upload/sign
- 将本地文件上传到签名目标
- 打印包含 fileurl 和 uploadurl 的 JSON
使用 fileurl 作为 imageurl、startimageurl、endimageurl,或作为基于图像的任务中 image_urls 内的一个项目。
支持的任务到上传映射:
- - image2image -> img2img
- imageupscale -> imgupscale
- backgroundremove -> bgremove
- singleimage2video -> img2video
- startendframe2video -> img2video
- multipleimage2video -> img2video
scripts/checkskillupdate.py
检查已安装的技能是否有适用于当前安装源的新版本可用。
bash
./.venv/bin/python scripts/checkskillupdate.py --mark-notified --check-interval-hours 24
用于开发/测试(当安装源元数据不可用时):
bash
./.venv/bin/python scripts/checkskillupdate.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
该脚本:
- - 首先检测安装源:clawhub 或 skills-github
- 对于 clawhub,读取已安装的 meta.json,并通过 clawhub inspect --json 获取最新版本
- 对于 skills-github,读取本地 SKILL.md 前置元数据的顶级 version 字段,回退到 metadata.version,查找 GitHub 源,并获取远程 SKILL.md 版本以及 CHANGELOG.md 的亮点(可用时)
- 打印包含 installsource、currentversion、latestversion、updateavailable 和 shouldnotify 的 JSON
- 当使用 --mark-notified 时,将最后通知的版本存储在本地状态文件中
- 缓存上次成功的版本检查,并通过 --check-interval-hours(默认 24)支持最小重新检查间隔
- 包含 changelog_preview,以便提醒可以提及主要亮点,而无需转储完整的变更日志
- 支持开发/测试覆盖,如 --install-source、--slug、--current-version 和 --github-source
参考文件
仅读取与当前需求匹配的参考文件。默认情况下不要加载所有文件。
任务执行参考
在选择模型、验证参数或将模糊的用户请求映射到推荐工作流时阅读这些文件:
- - references/imagemodels.md — 图像模型 ID、T2I/I2I 能力、每个模型的参数约束(分辨率、比例、输入限制、最大参考图像数)
- references/videomodels.md — 视频模型 ID、T2V/I2V/SE/MI 能力、每个模型的参数约束(时长、分辨率、比例、输入限制、音频)
- references/parameterreference.md — 所有 8 种任务类型的完整函数签名和参数表
- references/imagescenarios.md — 图像生成(T2I、I2I、工具)的场景到模型映射;当用户意图不明确时阅读
- references/video_scenarios.md — 视频生成(T2V、I2V、SE、MI)