Documentation

Video Generation Pipeline: Prompt to 30-Second Social Clip

Agent pattern for automated social-video production: prompt -> Sora 2 Pro or Veo 3.1 -> S3 upload -> webhook -> scheduled post.

Pattern type: Async generation + webhook delivery Tools used: sora-2-pro or veo-3.1, /api/webhooks, S3, social scheduler Estimated cost per 30-sec clip: $0.60

What this pattern does

A content team drops a one-line prompt into a queue. An agent picks it up, routes it to either Sora 2 Pro (cinematic) or Veo 3.1 (realism), waits for the async job to finish via webhook, uploads the result to S3, and hands the public URL to a social scheduler. No human waits on a loading spinner.

Video generation is slow (30-180s per clip), so the webhook pattern is essential — a synchronous request would tie up a worker for minutes.

Workflow

prompt queue
   -> /v1/run model=sora-2-pro  (async, webhook_url set)
   -> return { job_id }
   ...
   [minutes later]
   -> POST /webhooks/video-done  { job_id, video_url }
         -> download video_url
         -> upload to S3
         -> enqueue social post

Runnable implementation

import os, requests, boto3
from flask import Flask, request

SB = "https://api.heybossai.com/v1"
KEY = os.environ["SKILLBOSS_API_KEY"]
s3 = boto3.client("s3")
app = Flask(__name__)

# 1. Submit a generation job (async)
def submit(prompt: str, model: str = "sora-2-pro"):
    r = requests.post(
        f"{SB}/run",
        headers={
            "Authorization": f"Bearer {KEY}",
            "Content-Type": "application/json",
            "X-Max-Cost-Usd": "1.00",
        },
        json={
            "model": model,
            "inputs": {"prompt": prompt, "duration": 30, "aspect_ratio": "9:16"},
            "async": True,
            "webhook_url": "https://my-app.example.com/webhooks/video-done",
        },
    )
    return r.json()["job_id"]

# 2. Receive webhook when generation finishes
@app.post("/webhooks/video-done")
def done():
    body = request.json
    if body.get("status") != "completed":
        return "", 200

    video = requests.get(body["output"]["video_url"]).content
    key = f"clips/{body['job_id']}.mp4"
    s3.put_object(Bucket="my-social-clips", Key=key, Body=video, ContentType="video/mp4")

    # Hand to scheduler
    requests.post(
        "https://api.buffer.example/queue",
        json={"media_url": f"https://cdn.example.com/{key}", "channels": ["tiktok", "reels"]},
    )
    return "", 200

if __name__ == "__main__":
    submit("A neon-lit Tokyo alley at night, slow dolly-in, cinematic 35mm film look")
    app.run(port=8080)

Cost breakdown (per 30-sec clip)

Both Sora 2 Pro and Veo 3.1 are priced per second of output video.

CallSkillUnit costUnitsSubtotal
Generate videosora-2-pro$0.02/second30 sec$0.60
Webhook delivery(free)1$0.00
S3 upload (out of SkillBoss)

Total per clip: $0.60 30 clips/day: $18/day = ~$540/month Cheaper variant: veo-3.1-fast at the same $0.02/sec but faster turnaround, lower fidelity.

Guardrails for this pattern

  • Per-call cap: X-Max-Cost-Usd: 1.00 — an extra-long clip cannot sneak through as $8.
  • Sub-wallet: put the video agent on its own sub-wallet with a weekly budget so a runaway loop cannot blow through credit.
  • Webhook signature: verify the signature on every incoming webhook before trusting video_url.
  • Server rules: cap total video spend per day via /api/wallet/rules.
  • Audit: the signed receipt records exact duration + model so you can match it against CFO expectations.

Going further

  • A/B route 50% of prompts to veo-3.1 and 50% to sora-2-pro, then track engagement to pick a winner.
  • Pre-rewrite the user prompt with claude-4-5-haiku to add cinematic detail — $0.001 extra per clip, noticeably better output.
  • Use /api/estimate before running a 100-clip backfill.

Try this pattern yourself with a free $0.50 trial:

curl -X POST https://www.skillboss.co/api/try/anonymous-wallet \
  -H "Content-Type: application/json" -d '{}'

Get started ->

See also: /use/sora-2-pro | /use/veo-3-1 | Playground


SkillBoss is an independent multi-provider gateway, not affiliated with any vendor listed. Trademarks belong to their owners. See our IP policy.

Video Generation Pipeline: Prompt to 30-Second Social Clip