diff --git a/skills/openshorts/README.md b/skills/openshorts/README.md new file mode 100644 index 0000000..9b4b954 --- /dev/null +++ b/skills/openshorts/README.md @@ -0,0 +1,57 @@ +# OpenShorts as an Agent Skill + +`SKILL.md` plus `reference.md` are an +[Agent Skill](https://github.com/agentskills/agentskills): an open standard +adopted by 26+ agent products, so this one folder installs in Claude Code, +OpenClaw, Hermes, Codex, Gemini CLI, Cursor and VS Code without changes. + +It teaches an agent to turn a long video into vertical 9:16 clips through the +OpenShorts API: which options actually produce good clips, which responses look +like errors but are not, and when to stop and ask the user. + +## Setup + +Create an API key (`osk_...`) in your account page at +[openshorts.app](https://www.openshorts.app/) and give it to the agent the way +that host stores credentials (`OPENSHORTS_API_KEY` where an env var is the +convention). The hosted free tier includes 20 minutes of source video per month +with a watermark; paid plans start at $12/month without one. OpenShorts is also +MIT-licensed and self-hostable, which needs a GPU machine, your own Google +Gemini key, and your own [Upload-Post](https://www.upload-post.com/) account for +the publishing steps. + +If the host speaks MCP, add the server too so the agent gets typed tools instead +of raw HTTP: + +```bash +claude mcp add --transport http openshorts https://mcp.openshorts.app/mcp \ + --header "Authorization: Bearer osk_..." +``` + +The skill works either way: with MCP it calls the tools, without it it calls the +REST API documented in `reference.md`. + +## Install + +**Claude Code.** Copy the folder into `~/.claude/skills/` for every project, or +a project's `.claude/skills/` for one: + +```bash +cp -r skills/openshorts ~/.claude/skills/ +``` + +**OpenClaw.** Copy it into your OpenClaw `skills/` directory, or install from +git with `openclaw add /`. + +**Hermes.** Skills live in `~/.hermes/skills/`; installing from the marketplace +runs a security scan first. + +**Anything else.** Drop the folder wherever that agent reads skills from. + +## Related + +- `cli/` is the same API as a zero-dependency CLI: `uvx openshorts process --wait`. +- `examples/n8n/` has the same pipeline as importable n8n workflows, including a + daily channel autopilot with Telegram approval. +- [openshorts.app/mcp](https://www.openshorts.app/mcp) documents the MCP server, + and [api.openshorts.app/docs](https://api.openshorts.app/docs) the full API. diff --git a/skills/openshorts/SKILL.md b/skills/openshorts/SKILL.md index e51c71c..0202484 100644 --- a/skills/openshorts/SKILL.md +++ b/skills/openshorts/SKILL.md @@ -1,7 +1,7 @@ --- name: openshorts -version: 1.0.0 -description: Turn long videos (podcasts, webinars, streams) into vertical 9:16 clips with subtitles and publish them to TikTok, Instagram Reels and YouTube Shorts via the OpenShorts API or MCP server. Use when the user wants to clip a video into shorts, restyle captions on a clip, schedule or post clips to social platforms, or automate a clipping pipeline. +version: 1.1.0 +description: Turn long videos (podcasts, webinars, streams) into vertical 9:16 clips with subtitles, re-cut them, and publish them to TikTok, Instagram Reels and YouTube Shorts via the OpenShorts API or MCP server. Use when the user wants to clip a video into shorts, find the best moments of a video, restyle captions on a clip, re-cut a clip, schedule or post clips to social platforms, or automate a clipping pipeline. homepage: https://www.openshorts.app/mcp metadata: openclaw: @@ -14,19 +14,21 @@ metadata: # OpenShorts: clip and publish video -OpenShorts turns a long video into 3-15 vertical clips (15-60s each) with -word-level subtitles burned in, then optionally publishes them. One job takes -minutes, not seconds: always work async (submit, then webhook or poll). +OpenShorts turns a long video into vertical 9:16 clips (15-60s each) with +word-level subtitles burned in, reframed so the speaker stays in shot, then +optionally publishes them. One job takes minutes, not seconds: always work async +(submit, then webhook or poll). ## Connect Two equivalent surfaces; prefer MCP when the client supports it: - **MCP** (streamable HTTP): `https://mcp.openshorts.app/mcp` with header - `Authorization: Bearer osk_...`. Six tools: `process_video`, - `get_job_status`, `list_clips`, `get_quota`, `add_subtitles`, `publish_clip`. -- **REST**: same key against `https://api.openshorts.app` (OpenAPI at - `/openapi.json`, docs at `/docs`). + `Authorization: Bearer osk_...`. Seven tools: `process_video`, + `get_job_status`, `list_clips`, `get_quota`, `add_subtitles`, `recut_clip`, + `publish_clip`. +- **REST**: same key against `https://api.openshorts.app`. Exact payloads and + error shapes are in `reference.md`; read it before the first HTTP call. Keys are created in the account page at openshorts.app and start with `osk_`. **Self-hosted instances expose the same endpoints on `http://localhost:8000` @@ -37,32 +39,78 @@ anonymous: there is no minute quota to enforce. 1. `get_quota` first when the job is large: `process_video` fails with `quota_exceeded` if minutes run out; on the hosted service API calls draw - from the same minute balance as the dashboard (no separate meter). + from the same minute balance as the dashboard (no separate meter). A job + costs its source duration rounded up, minimum one minute. 2. Submit: `POST /api/process` with JSON - `{"url": "...", "acknowledged": true}`. Optional: `layouts` - (`"auto,split,screencast"`), `output_format` (`"1080p"`), `webhook_url` + - `webhook_secret`. Returns `{"job_id": ...}` immediately. + `{"url": "...", "acknowledged": true}`. Returns `{"job_id": ...}` + immediately. See the next section for the options worth setting. 3. Finish: **webhooks beat polling.** With `webhook_url` set, OpenShorts POSTs exactly once when the job ends (completed OR failed, so pipelines never hang): `{"event": "job.completed", "job_id", "status", "clips": [{"index", "title", "video_url", "download_url"}]}`. If a secret was set, verify `X-OpenShorts-Signature: sha256=` = HMAC-SHA256 of the raw body. - Without a webhook, poll `GET /api/status/{job_id}` every ~10s; response is + Without a webhook, poll `GET /api/status/{job_id}` every 30-60s; response is `{"status", "logs", "result"}` and `result.clips` appears on completion. 4. Publish: `POST /api/social/post` with `{"job_id", "clip_index", "platforms": ["tiktok", "instagram", "youtube"]}`, optional `title`, - `scheduled_date` (ISO) + `timezone`. Restyle captions first if asked: + `scheduled_date` (ISO) + `timezone`. TikTok lands as a draft in the app; + Instagram and YouTube publish directly. Restyle captions first if asked: `POST /api/subtitle` with `{"job_id", "clip_index", "style"}` (`classic` - or karaoke word highlighting). + or `karaoke` word highlighting). + +## The choices the API cannot make for you + +**How many clips.** Leave `target_clips` unset by default: the AI decides, and +most videos yield two to six. It is a target (1-15), not a guarantee. Asking a +short video for 15 clips does not produce 15 good ones, it produces the same +handful plus filler. + +**Clip length.** `clip_min_seconds` / `clip_max_seconds` default to 15 and 60, +which is what the platforms reward. The max must sit at least 5 seconds above +the min. + +**Aspect.** `output_format` is `auto` (vertical 9:16, what shorts want), +`vertical`, `horizontal` or `square`. It is not a resolution. + +**Layouts.** Leave `layouts` empty unless you know the footage. The useful value +is `["auto"]`: one cheap AI call per source picks between no change, a +screencast layout and a split layout. The rest are manual overrides. +`split` stacks two people who are visible in the *same* frame, and is wrong for +shot/reverse-shot footage where it would show one person twice. `screencast` is +for scenes whose meaning lives outside the centre (a demo, slides, a +spreadsheet) that a plain crop would cut away. `speaker_cut` hard-cuts to +whoever is talking. `punch_in` is not a layout, it is a subtle push on the +clip's beats and composes with the others. + +**Re-cutting.** `recut_clip` (`POST /api/clip/rerender`) takes an ordered list of +segments in seconds **of the original source video**, not of the clip, so you +can trim, extend, drop a dead moment in the middle, or reorder. Pass +`snap_to_words: true` so the boundaries land on word edges. + +## Three responses that are not failures + +- **`needs_confirmation`** comes back with HTTP 200, not an error: the best + available source resolution is below the quality gate. Ask the user, then + resubmit the same body with `force_low_quality: true`. Never retry + automatically: the job still costs minutes and low resolution in means low + resolution out. +- **HTTP 402 `quota_exceeded`** means out of minutes, with `minutes_required` + and `minutes_remaining` in the body. Report it and stop. Do not retry and do + not split the video to squeeze under the limit. +- **HTTP 429** means the user already has the maximum number of jobs running. + Wait for one to finish instead of resubmitting. ## Rules - Only submit videos the user has rights to; `process_video` requires the `confirm_rights` acknowledgement and that is deliberate. +- Publishing is public and irreversible: confirm platforms and caption with the + user before every `publish_clip` call. - `download_url` links are presigned for 24h: fetch or forward them promptly. - Never describe OpenShorts as simply "free": the self-hosted edition is free - and MIT-licensed; the hosted service has 20 free minutes/month (watermarked) - and paid plans from $12/month without watermark. + and MIT-licensed (and needs a GPU box plus your own Gemini key); the hosted + service has 20 free minutes/month (watermarked) and paid plans from $12/month + without watermark. ## CLI shortcut diff --git a/skills/openshorts/reference.md b/skills/openshorts/reference.md new file mode 100644 index 0000000..498e2af --- /dev/null +++ b/skills/openshorts/reference.md @@ -0,0 +1,165 @@ +# OpenShorts HTTP reference + +Base URL: `https://api.openshorts.app` (self-hosted: `http://localhost:8000`). +Every call carries `Authorization: Bearer osk_...` or `X-API-Key: osk_...`. +Self-hosted instances need no key, but do need a Gemini key, either in the +server's environment or as an `X-Gemini-Key` header. + +The MCP server at `https://mcp.openshorts.app/mcp` wraps exactly these +endpoints, forwarding your auth headers, so the two paths cannot drift. + +## Quota + +`GET /api/me` + +```json +{ + "plan": "free", + "entitled": false, + "minutes": { "plan_allowance": 20, "plan_used": 4, "plan_remaining": 16, + "topup_remaining": 0, "remaining": 16 }, + "upload_post_profile": null +} +``` + +`upload_post_profile` is null when no social account is connected, which means +publishing will fail. On a self-hosted instance this endpoint is not mounted at +all and returns 404, which simply means there is no quota to report. + +## Start a job + +`POST /api/process`, JSON body for a URL source (use multipart form fields with +a `file` part to upload a local video instead): + +```json +{ + "url": "https://www.youtube.com/watch?v=...", + "acknowledged": true, + "layouts": ["auto"], + "output_format": "auto", + "target_clips": 4, + "clip_min_seconds": 15, + "clip_max_seconds": 60, + "webhook_url": "https://example.com/hooks/openshorts", + "webhook_secret": "change-me", + "force_low_quality": false +} +``` + +`acknowledged: true` is the rights attestation and is required. `layouts` +accepts a JSON list or a comma separated string of `auto`, `split`, +`screencast`, `speaker_cut`, `punch_in`. `output_format` is one of `auto`, +`vertical`, `horizontal`, `square`. `target_clips` is 1 to 15; +`clip_min_seconds` 5 to 175; `clip_max_seconds` 10 to 180 and at least 5 above +the minimum. + +Success: + +```json +{ "job_id": "0f0a...", "status": "queued" } +``` + +Quality gate, also HTTP 200: + +```json +{ "needs_confirmation": true, + "quality_check": { "max_height": 480, "min_height": 720, "cookies_invalid": false } } +``` + +Ask the user, then resubmit the identical body with `force_low_quality: true`. + +Errors: **402** `{"detail": {"error": "quota_exceeded", "minutes_required": 12, +"minutes_remaining": 3}}`, **429** too many jobs already running, **400** the +source duration could not be determined. + +## Poll a job + +`GET /api/status/{job_id}` returns `{"status": ..., "logs": [...], "result": ...}` +where status is `queued`, `processing`, `completed` or `failed`. `result.clips` +appears once completed, each entry carrying `title`, +`video_title_for_youtube_short`, `video_description_for_tiktok`, +`video_description_for_instagram`, `start`, `end` and `video_url`. A relative +`video_url` is relative to the API base. + +Poll every 30 to 60 seconds. Prefer a webhook. + +## Webhook + +Fired once per job, on success and on failure, so a flow never hangs: + +```json +{ + "event": "job.completed", + "job_id": "0f0a...", + "status": "completed", + "clips": [ { "index": 0, "title": "...", "video_url": "...", "download_url": "..." } ] +} +``` + +A failed job sends `"event": "job.failed"` with an `error` string and no clips. +`download_url` is a presigned link valid for 24 hours (hosted service only). + +The URL must be public HTTPS; it is validated at submit time and re-resolved at +delivery time, so a URL that points at a private address is refused. With a +`webhook_secret`, the **raw request body** is signed HMAC-SHA256 and sent as +`X-OpenShorts-Signature: sha256=`. Verify against the raw bytes, not +against a re-serialized object: + +```javascript +const crypto = require('crypto'); +const expected = 'sha256=' + crypto + .createHmac('sha256', secret) + .update(rawBody) + .digest('hex'); +``` + +## Restyle captions + +`POST /api/subtitle` + +```json +{ "job_id": "...", "clip_index": 0, "style": "karaoke", "position": "bottom", + "font_size": 48, "font_name": "...", "font_color": "#FFFFFF", + "highlight_color": "#FFE600", "uppercase": true } +``` + +`style` is `classic` or `karaoke`; `position` is `top`, `middle` or `bottom`. +Only `job_id` and `clip_index` are required. + +## Re-cut a clip + +`POST /api/clip/rerender` + +```json +{ "job_id": "...", "clip_index": 0, + "segments": [ { "start": 812.4, "end": 831.0 }, { "start": 840.2, "end": 858.9 } ], + "snap_to_words": true, "reapply_captions": true, "framing": "auto" } +``` + +Times are seconds in the **original source video**. Segments concatenate in the +order given. `framing` is `auto`, `full` (no side cropping) or `track` (force +subject tracking); omit it to keep the clip's current framing. Anything outside +the clip's original range, or any non-auto `framing`, re-runs the reframe engine +and needs the retained source video. + +## Publish + +`POST /api/social/post` + +```json +{ "job_id": "...", "clip_index": 0, "platforms": ["tiktok", "instagram", "youtube"], + "title": "...", "description": "...", + "scheduled_date": "2026-08-25T18:00:00Z", "timezone": "Europe/Madrid" } +``` + +Omit `scheduled_date` to post now. Uploads are asynchronous. TikTok arrives as a +draft in the app; Instagram and YouTube publish directly. + +Queue: `GET /api/social/scheduled`, and +`DELETE /api/social/scheduled/{job_id}` to cancel one before it goes out. + +Analytics of what was published: `GET /api/social/analytics` (profile totals), +`GET /api/social/analytics/posts` (per post), and +`GET /api/social/analytics/impressions` (windowed, e.g. `?period=last_week`). + +Full generated API docs: .