ClipSDK Python Quickstart
Automate short-form video clipping in Python 3 with zero third-party SDK dependencies. Create clips, long-poll job status, upload 5 GB local files, and download MP4 + SRT files.
Get Your ClipSDK API Key
ClipSDK authenticates every /v1/* endpoint with Authorization: Bearer csdk_live_... and gives every new account a $0 free first video up to 60 minutes.
Generate a live key in the dashboard at clipsdk.com/dashboard/keys and export it as CLIPSDK_KEY. Never embed live keys in browser bundles; call https://api.clipsdk.com from your backend or connect AI agents through https://mcp.clipsdk.com/mcp.
export CLIPSDK_KEY="csdk_live_replace_with_your_key"Create Ranked Clips in Python
Send one POST https://api.clipsdk.com/v1/clips request in Python with an Idempotency-Key header to transcribe, rank, reframe to 9:16, and burn karaoke captions automatically.
import json
import os
import time
import urllib.error
import urllib.request
import uuid
API_KEY = os.environ["CLIPSDK_KEY"]
BASE = "https://api.clipsdk.com"
def api_call(method: str, path: str, body=None, idempotency_key: str | None = None):
headers = {"Authorization": f"Bearer {API_KEY}", "Accept": "application/json"}
data = None
if body is not None:
headers["Content-Type"] = "application/json"
data = json.dumps(body).encode("utf-8")
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
req = urllib.request.Request(f"{BASE}{path}", data=data, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=90) as resp:
retry_after = int(resp.headers.get("Retry-After", "5"))
return resp.status, retry_after, json.loads(resp.read().decode("utf-8"))
status, retry_after, payload = api_call(
"POST",
"/v1/clips?wait=60",
{
"video_url": "https://www.youtube.com/watch?v=VIDEO_ID",
"clips": 5,
"min_seconds": 20,
"max_seconds": 60,
"aspect": "9:16",
"reframe": "auto",
"captions": "karaoke",
"hook": True,
},
idempotency_key=f"quickstart-{uuid.uuid4().hex}",
)
job = payload["job"]
while job["status"] in ("queued", "running"):
time.sleep(retry_after)
status, retry_after, payload = api_call("GET", f"/v1/jobs/{job['id']}?wait=60")
job = payload["job"]
if job["status"] != "succeeded":
raise RuntimeError(f"ClipSDK job failed: {job['error']}")
for clip in job["result"]["clips"]:
print(f"#{clip['rank']} [{clip['score']}/100] {clip['title']} -> {clip['video']}")Inspect Returned Clips & Scores
ClipSDK returns HTTP 200 once a job finishes, sorting clips best-first with 0-100 standalone scores, MP4 links, JPG posters, SRT/VTT captions, and billing metadata.
{
"job": {
"id": "job_3k9x0c2m1q8w7e6r5t4y",
"op": "clips",
"status": "succeeded",
"stage": null,
"usage": { "source_minutes": 42.5, "clips": 5, "output_seconds": 214.8 },
"pricing": { "basis": "source_minutes", "reason": null, "quality_multiplier": 1 },
"result": {
"source": { "duration_s": 2550, "language": "en", "speakers": null },
"clips": [
{
"rank": 1,
"score": 92,
"title": "Why usage-based video APIs beat seat licenses",
"reason": "Opens with a bold claim and lands a concrete math proof in 41 seconds.",
"start_s": 412.4,
"end_s": 453.6,
"duration_s": 41.2,
"post_caption": "Flat seat subscriptions punish irregular publishing schedules...",
"video": "https://api.clipsdk.com/f/clip_1_1080x1920.mp4",
"poster": "https://api.clipsdk.com/f/clip_1_poster.jpg",
"srt": "https://api.clipsdk.com/f/clip_1.srt",
"vtt": "https://api.clipsdk.com/f/clip_1.vtt"
}
],
"locked": null
},
"error": null,
"poll_url": "https://api.clipsdk.com/v1/jobs/job_3k9x0c2m1q8w7e6r5t4y"
}
}| Score Band | Meaning | Recommended Action |
|---|---|---|
80-100 | Strong standalone hook and payoff for cold viewers | Auto-publish or queue straight to Shorts, Reels, and TikTok |
50-79 | Good insight that benefits from a sharper opening title | Add or tune a hook headline or trim opening filler via /edit |
0-49 | Context-dependent or housekeeping moment | Filter out automatically or request extra cuts with from_job |
Upload Local Video Files in Python
ClipSDK supports local MP4, MOV, WebM, and MKV files up to 5 GB through POST /v1/uploads, returning a 1-hour presigned PUT URL and 7-day video_url.
Include Authorization: Bearer csdk_live_... on POST /v1/uploads, then omit Authorization on the direct PUT to upload_url and send the exact Content-Length byte count.
import json, os, urllib.request
API_KEY = os.environ["CLIPSDK_KEY"]
path = "./episode-42.mp4"
size = os.path.getsize(path)
req = urllib.request.Request(
"https://api.clipsdk.com/v1/uploads",
data=json.dumps({"filename": os.path.basename(path), "size": size}).encode("utf-8"),
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req, timeout=30) as resp:
ticket = json.loads(resp.read().decode("utf-8"))
# PUT raw bytes directly to storage without an Authorization header
with open(path, "rb") as fh:
put_req = urllib.request.Request(
ticket["upload_url"],
data=fh,
headers={"Content-Length": str(size)},
method="PUT",
)
with urllib.request.urlopen(put_req, timeout=600) as put_resp:
assert 200 <= put_resp.status < 300
print("Ready for POST /v1/clips:", ticket["video_url"])Sync Wait vs Async Webhooks
Use ?wait=60 for CLI scripts and short videos, or send Prefer: respond-async with webhook_url in production SaaS backends to avoid tying up HTTP workers.
| Mode | Request Option | Best Fit |
|---|---|---|
| Long-poll create | POST /v1/clips?wait=60 (max 300) | CLI scripts, agent tools, and short 1-10 minute sources |
| Immediate async | ?wait=0 or Prefer: respond-async | Web apps queueing work and listening on webhook_url |
| Safe retries | Idempotency-Key: <unique-id> (24h TTL) | Network retry loops without duplicating render spend |
Next Steps After Your First Clip
Move from quickstart to production with full parameter schemas, custom caption presets, HMAC-SHA256 webhook verification, and AI agent skills.
- Inspect every field for
/v1/clips,from_job, and word-level/editin Clips & Jobs Reference. - Customize burned-in typography, 8 presets, hook templates, and
bleepin Captions & Hooks. - Verify signed
job.succeededevents with replay protection in Webhooks. - Grab ready-made production scripts and agent
SKILL.mdfiles from bitgate/clipsdk-api-skills.