Fotor OpenAPI skill for AI image generation, AI photo editing, AI video generation, product photos, ad creatives, social media graphics, background removal, photo restoration, and image upscaling.
This skill should match user requests expressed in outcome language first, not SDK language. Keep technical details behind the scenes unless they are needed to unblock execution.
Use this skill when the user asks for outcomes such as:
Common search phrases this skill should be able to match include:
For API key application and product details, see https://developers.fotor.com/fotor-skills/.
Use uv as the bootstrap layer. Prefer a skill-local Python 3.12 environment and run bundled scripts from that local environment instead of the system Python.
Keep setup lightweight and local to the skill directory.
Install uv first if it is missing:
# 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"
Typical first-run setup:
uv python install 3.12
uv venv --python 3.12 .venv
./.venv/bin/python scripts/ensure_sdk.py
Setup rules:
uv to prepare Python 3.12 and create .venv when the local environment is missing.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:
./.venv/bin/python.venv\\Scripts\\python.exeuv before installing dependencies or executing the task. Avoid installing into the system Python unless the user explicitly asks.references/credits-and-recharge.md and follow its recharge guidance flow.references/credits-and-recharge.md to explain the failure and provide recharge guidance.scripts/ensure_sdk.pyCross-platform (Windows / macOS / Linux) script to install or upgrade fotor-sdk to the latest PyPI release with uv pip install --python . Run before every task.
--upgrade — same behavior, kept as an explicit aliasscripts/run_task.pyExecute one or more Fotor tasks from JSON. Handles client init, polling, and progress.
Single task:
echo '{"task_type":"text2image","params":{"prompt":"A cat","model_id":"seedream-4-5-251128"}}' \
| ./.venv/bin/python scripts/run_task.py
Batch (array):
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
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:
task_type + model_id matches a built-in fallback mapping, run_task.py automatically retries once with the fallback model.code=510 / No enough credits), run_task.py returns the failure immediately and does not retry on a fallback model.fallback_used, original_model_id, and fallback_model_id.scripts/upload_image.pyUpload a local image file through Fotor's signed upload flow and return a reusable image URL.
./.venv/bin/python scripts/upload_image.py ./input.jpg --task-type image2image
The script:
/v1/upload/sign with the mapped upload type and suffixfile_url and upload_urlUse 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 -> img2imgimage_upscale -> img_upscalebackground_remove -> bg_removesingle_image2video -> img2videostart_end_frame2video -> img2videomultiple_image2video -> img2videoscripts/check_skill_update.pyCheck whether the installed skill has a newer version available for the current install source.
./.venv/bin/python scripts/check_skill_update.py --mark-notified --check-interval-hours 24
For development/testing when install-source metadata is unavailable:
./.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
The script:
clawhub or skills-githubclawhub, reads installed _meta.json and fetches the latest version via clawhub inspect --json 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 availableinstall_source, current_version, latest_version, update_available, and should_notify--mark-notified is used--check-interval-hours (default 24)changelog_preview so the reminder can mention the main highlights without dumping the full changelog--install-source, --slug, --current-version, and --github-sourceOnly read the reference files that match the current need. Do not load all of them by default.
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)references/video_models.md -- video model IDs, T2V/I2V/SE/MI capabilities, per-model parameter constraints (duration, resolution, ratios, input limits, audio)references/parameter_reference.md -- full function signatures and parameter tables for all 8 task typesreferences/image_scenarios.md -- scenario-to-model mapping for image generation (T2I, I2I, utilities); read when user intent is ambiguousreferences/video_scenarios.md -- scenario-to-model mapping for video generation (T2V, I2V, SE, MI); read when user intent is ambiguousRead 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 handlingreferences/get_api_key.md -- guide for giving the official fotor-skills homepage, sending users to the API-key dashboard entry, and configuring FOTOR_OPENAPI_KEYreferences/install-or-upgrade.md -- how to install or upgrade fotor-skills for both ClawHub and npx skills, and how to phrase a concise non-pushy upgrade reminderuv is missing, install it first using the platform-appropriate installer shown in Setup.uv, run uv python install 3.12..venv is missing, create it with uv venv --python 3.12 .venv../.venv/bin/python scripts/ensure_sdk.py before every task to install or upgrade the latest fotor-sdk with uv..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.fotor-skills homepage during setup, read references/get_api_key.md and include both links before expanding into lower-level setup details.FOTOR_OPENAPI_KEY is set.references/credits-and-recharge.md, then use the appropriate balance or payment-links flow from that reference../.venv/bin/python scripts/upload_image.py --task-type and keep the returned file_url.model_id. Each model's per-model spec section lists supported resolutions, aspect ratios, duration, input constraints, and max reference images.image_scenarios.md / video_scenarios.md) for recommended model + params../.venv/bin/python scripts/run_task.py (works for both single and batch)..venv interpreter.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 are defined in references/fallback_models.json.
run_task.py reads that file directly. Keep exact fallback pairs there instead of duplicating them in SKILL.md or scenario references.
| task_type | Function | Required Params |
|---|---|---|
| ----------- | ---------- | ----------------- |
text2image | text2image() | prompt, model_id |
image2image | 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.
For any balance lookup, recharge guidance, or insufficient-credit case, read references/credits-and-recharge.md.
Keep SKILL.md focused on routing:
code=510 or No enough credits.When scripts/run_task.py is insufficient (custom logic, chaining, progress callbacks):
import os
from fotor_sdk import FotorClient
client = FotorClient(api_key=os.environ["FOTOR_OPENAPI_KEY"])
from fotor_sdk import text2image
result = await text2image(client, prompt="A diamond kitten", model_id="seedream-4-5-251128")
print(result.result_url)
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)
from fotor_sdk import text2video
result = await text2video(client, prompt="Jazz band", model_id="kling-v3",
audio_enable=True, audio_prompt="Smooth jazz")
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)
FotorAPIError (has .code attribute).result.success per item; runner never raises on individual failures.error="NSFW_CONTENT" in TaskResult.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).
共 1 个版本