Automating video generation means driving a video model from code instead of a chat box. On Moosky that is four calls: exchange an API key for a token, queue a run with a model slug and a prompt, poll the status (or let a webhook push it), and read back the finished file — all from one credit balance, the same one that funds the studio. No per-provider keys, GPU boxes, or vendor SDKs to wire up. This guide walks the whole loop end to end with working curl and Python, quotes the real per-clip cost on Moosky's published pricing, and ends by comparing it to assembling your own provider stack so you pick by the job, not by novelty. It is the doing side of the AI Video Generation API page — the workflow and the bill, not the pitch.

Quick answers

How do you automate video generation with an AI video API? Get an API key from the developer page, POST the key pair to the token endpoint for a bearer token, then queue runs at the executions endpoint with a model slug and your selections. Poll the execution by id, or register a webhook so the finished file is pushed to you instead of you polling for it.

What does it cost per clip? On Moosky, 100 credits = US$1 and you pay per run, not per month. A 5-second clip at 720P on Wan 3.0 is 77 credits (about $0.77); the same clip at 1080P is 154; a 3-second hero frame at 480P drafts for 24. Every run quotes its exact cost at the estimate endpoint before anything is queued, and failed runs refund themselves. A full batch of fifty 4-second social drafts on the budget engine lands around 3,300 credits (about $33).

Can you generate video from a script or a cron job? That is the point. Loop your prompt rows, fire one queue call per line, and collect the files from the status response or a webhook. Teams wire it into Python workers, n8n, and Make the same way they would call any other REST service.

Do you need a separate subscription for API access? No. One credit balance funds the studio, the no-code tools, and the API at the same per-run rate. There is no API tier, no seat license, and no monthly floor — you buy credits and spend them.

Which models can you call? Everything the live registry exposes, queried from code: a GET on the scene-composer list returns the current video, image, and upscaling engines with their slugs and capabilities, so your automation discovers the lineup instead of hard-coding a stale one.

Is there a rate limit? Key creation is throttled as an abuse guard. For sustained high volume — large catalogs, steady throughput — email support@moosky.ai and agree numbers before you build around a wall.

The API surface in one view

Every automation is the same shape. The base is https://api.moosky.ai; the whole thing is documented in a Swagger UI at api.moosky.ai/docs generated from the routes that actually serve you, so the parameters you see are the parameters that run.

Step Call Auth What it gives you
Get a key Create it on /developer (one-time) — A client_id and client_secret (the secret shows once)
Token POST /auth/api-key/token none A bearer token for every later call
Price it POST /executions/estimate-cost none The exact credit cost of a run, before you spend
Queue it POST /scenes/{id}/executions bearer An execution with an id and a status
Read it back GET /scenes/{id}/executions/{executionId} bearer status and storagePath once the render lands
Or skip polling POST /webhooks bearer A signed push when an execution's state changes

The one object to understand is the execution — a single generation job. It carries a status (queued to completed, with a statusMsg while it runs), and a storagePath that fills in with the finished file only when the render is done. Your loop is: queue, then watch that status until it flips and storagePath is no longer null.

Setup: key, token, first quote

Create a free account, open the developer page, and create a named key. Copy the client secret immediately — it is shown once and never again. Then run the whole handshake from the shell.

curl

# 1) Exchange the key pair for a bearer token
curl -s -X POST "https://api.moosky.ai/auth/api-key/token" \
  -H "Content-Type: application/json" \
  -d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'
# -> { "token": "<jwt>", ... }     export TOKEN="<the token>"

# 2) Create a scene to own your runs (POST /scenes returns its id)
curl -s -X POST "https://api.moosky.ai/scenes" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"my first api scene"}'
# -> { "id": 42 }                   export SCENE_ID=42

# 3) Quote the run before you spend — this is a public endpoint, no auth
curl -s -X POST "https://api.moosky.ai/executions/estimate-cost" \
  -H "Content-Type: application/json" \
  -d '{"sceneComposerSlug":"wan30-scene-composer","selections":[{"optionSlug":"prompt","value":{"value":"a drone shot over pine forest at sunrise"}}]}'
# -> { "credits": 47 }

# 4) Queue it, then read it back
curl -s -X POST "https://api.moosky.ai/scenes/$SCENE_ID/executions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sceneComposerSlug":"wan30-scene-composer","selections":[{"optionSlug":"prompt","value":{"value":"a drone shot over pine forest at sunrise"}}]}'
# -> { "id": 36849, "status": "queued", ... }   export EXEC_ID=36849

curl -s "https://api.moosky.ai/scenes/$SCENE_ID/executions/$EXEC_ID" \
  -H "Authorization: Bearer $TOKEN"
# -> { "status": "completed", "storagePath": "<engine-dir>/<id>_<hash>.mp4", ... }  (null while queued)

The estimate-cost call is the one that makes automation safe to run unattended: it returns the exact credit cost with no side effects, so your code can decide whether a run is worth it before it touches your balance.

Python

A real worker wants the same four steps as functions, plus a poll loop. This is tested against the live endpoints:

import os
import time
import requests  # pip install requests

API = "https://api.moosky.ai"

def get_token() -> str:
    r = requests.post(f"{API}/auth/api-key/token", json={
        "client_id": os.environ["MOOSKY_CLIENT_ID"],
        "client_secret": os.environ["MOOSKY_CLIENT_SECRET"],
    }, timeout=30)
    r.raise_for_status()
    return r.json()["token"]

def quote(slug: str, prompt: str) -> int:
    r = requests.post(f"{API}/executions/estimate-cost", json={
        "sceneComposerSlug": slug,
        "selections": [{"optionSlug": "prompt", "value": {"value": prompt}}],
    }, timeout=30)
    r.raise_for_status()
    return r.json()["credits"]

def queue(token: str, scene_id: int, slug: str, prompt: str) -> int:
    r = requests.post(f"{API}/scenes/{scene_id}/executions",
                      headers={"Authorization": f"Bearer {token}"}, json={
        "sceneComposerSlug": slug,
        "selections": [{"optionSlug": "prompt", "value": {"value": prompt}}],
    }, timeout=30)
    r.raise_for_status()
    return r.json()["id"]

def wait(token: str, scene_id: int, exec_id: int, timeout=900) -> str:
    """Poll until the execution completes and its storagePath fills in."""
    deadline = time.time() + timeout
    while time.time() < deadline:
        r = requests.get(f"{API}/scenes/{scene_id}/executions/{exec_id}",
                         headers={"Authorization": f"Bearer {token}"}, timeout=30)
        r.raise_for_status()
        ex = r.json()
        if ex["status"] == "completed" and ex.get("storagePath"):
            return f"{API}/stream/public/{ex['storagePath']}"
        if ex["status"] in ("failed", "cancelled"):
            raise RuntimeError(f"run {exec_id} {ex['status']}: {ex.get('statusMsg')}")
        time.sleep(5)
    raise TimeoutError(f"run {exec_id} not done in {timeout}s")

token = get_token()
scene_id = int(os.environ["MOOSKY_SCENE_ID"])    # from step 2: POST /scenes returns its id
prompt = "a drone shot over pine forest at sunrise"
cost = quote("wan30-scene-composer", prompt)     # -> 47 for a short draft
if cost <= 200:                                  # only spend what you approve
    eid = queue(token, scene_id, "wan30-scene-composer", prompt)
    print("finished file:", wait(token, scene_id, eid))

Swap in the scene_id from step 2 (POST /scenes returns it, or reuse a studio scene id — a key on someone else's scene gets a 404). The sceneComposerSlug picks the model — wan30-scene-composer, ltx-2-5-scene-composer, and the rest come from the registry — and the selections array carries the inputs, so prompt here generalises to the option set each composer advertises.

Webhooks: stop polling

If you are queueing more than a handful of runs, register a webhook once and let the finished file be pushed to you instead of sitting in a poll loop:

requests.post(f"{API}/webhooks",
              headers={"Authorization": f"Bearer {token}"}, json={
    "url": "https://your-server.example/webhooks/scene-execution",
    "event_types": ["scene_execution.status.updated"],
}, timeout=30)
# -> { "endpoint": { "id": 10, ... }, "secret": "<signing secret — shown once>" }

Each delivery carries X-Webhook-Event, X-Webhook-Id, X-Webhook-Timestamp, and an X-Webhook-Signature header — an HMAC-SHA256 of <timestamp>.<raw_body> computed with your endpoint secret. Verify the signature and return a 2xx, or the delivery is retried with backoff, so make your handler idempotent. Your key only receives events for executions on your own account.

What a run actually costs, before you automate

Automation changes the economics question from "what does a clip cost" to "what does a thousand clips cost," so budget on the published list prices rather than guessing. Everything is quoted in credits at a fixed 100 credits = US$1, bought in packages, no subscription, credits never expiring, and the exact number appears on the run button and at the estimate endpoint before anything dispatches. These are the live prices from the engines' pricing code, identical to the figures in the Wan 3.0 workflow guide and the per-usable-clip breakdown:

Wan 3.0 (hero motion) — flat duration × resolution, rounded per second, no base fee:

Clip length 480P (draft) 720P 1080P (hero)
3s (default) 24 47 93
5s 39 77 154
10s 77 154 308
15s 116 231 462
30s (max) 231 462 924

(The 47 you saw from the estimate endpoint is the 3s/720P cell.)

LTX 2.5 (cheap drafts) — billed per second of output, flat by resolution tier: a 4-second 720P draft is 66 credits (about $0.66), an 8-second 720P draft is 121, a 10-second 4K master is 472. Draft at 720P, lock the take, and only then spend the premium tiers once, on the shot you kept.

FlashVSR (the upscaling pass) — billed by the second of output, from roughly 1.6 credits per second at 720P up to 4.2 at 4K: a 10-second clip to 720P is 16 credits, a one-minute clip to 4K is 250 credits ($2.50). The full per-second grid and the failure list live in how to upscale a video with AI.

A worked batch bill. Say you need fifty vertical social clips plus a couple of hero masters. Draft all fifty at LTX 720P 4s: 50 × 66 = 3,300 credits (about $33). Promote the six keepers to Wan 3.0 1080P 5s: 6 × 154 = 924 credits (about $9.24). Upscale one 30-second hero to 4K: about 125 credits. Whole batch including the drafts that did not survive: roughly 4,349 credits, about $43 — on a balance you top up per campaign, with failures refunded and nothing billed for a dead run. The per-usable-clip economics (why you budget for re-takes, not just hits) are worked out in the cost guide linked above.

When an API beats a UI

The studio is the right tool when a person is choosing the shot. The API is the right tool the moment the work is a list or a schedule, and there are three jobs where that line is obvious:

Batch social variants. Fifty hooks, twelve products, one brand kit, a grid of aspect ratios — a list you can hold in a spreadsheet. In the UI you would re-pick settings fifty times; in code you loop the prompt rows, queue one run per line on the cheap engine, and keep only the winners. Same pattern as the AI video generator, minus the clicking.

Programmatic upscaling. A nightly job that takes yesterday's finished renders and pushes the keepers to 4K through the FlashVSR or SeedVR2 image upscaler composer needs no human in the loop — queue it, let the webhook drop the file, done. See how to upscale a video with AI for the engine pick; the API just removes the clicking.

Scheduled and triggered generation. Cron, CI, a queue consumer, a webhook from your CMS. The article-to-video and script-to-video passes become one call each, so a new post or a new product feed can mint its own clip the moment it lands. The no-code path covers a lot of this too — see the bulk video generator — but code is where it becomes triggered instead of batched-by-hand.

API vs building your own provider stack

The alternative to a hosted API is wiring the models up yourself: rent GPU boxes or stitch several vendor SDKs together, add a queue, and glue it into one pipeline. It is a real option, and for some teams the right one — so it is worth being straight about the tradeoff.

Hosted API (Moosky) Build your own provider stack
Setup One key, four REST calls GPUs or several vendor SDKs, a queue, model ops
Models One balance reaches video, image, and upscale engines One integration and one bill per model you add
Pricing Credits per run, quoted before it fires Compute idle cost plus per-model vendor billing
Failed runs Refund to your balance automatically You build the retry, refund, and idempotency logic
Discovery Query the live registry for current engines and slugs You track every model version and breaking change
The catch Shared service, agreed rate limits You own availability, scaling, and maintenance

The honest version: you pick a self-built stack when you need bespoke models, hard data residency, or throughput so large that owning the compute pays for the engineering. For everything else the hosted API is doing the same job — queue a run, get a file, pay per clip — without the four vendor dashboards, four rate limits, and one on-call rotation to babysit. The per-engine credit math above is the same whether the run came from the studio or from your script, which is the point: the API is a different front door onto one balance, not a second product with its own bill.

The prompt-engineering half of this (what to write so a clip comes back usable) is not an API concern and is covered separately in the 50 AI video prompt examples and the LTX prompt playbook; this guide owns the call sequence, the polling, and the bill.

Frequently asked questions

Do I need to install an SDK? No. The API is plain HTTPS JSON — five curl calls or a requests loop, as above. There is no official client to install, and none of the examples need one.

What is the request body to queue a video? A sceneComposerSlug (the model) and a selections array of {optionSlug, value} objects (the inputs, at minimum the prompt). The options per model are discoverable from the scene-composer list, so you read the exact option slugs instead of guessing.

How long until a clip is ready? It depends on the engine and the length; the execution moves from queued to completed and storagePath fills in when the file is there. For anything beyond a few runs, register a webhook and stop watching the clock.

How do I get the finished file back? Read storagePath off the completed execution and pull it from the public stream path (https://api.moosky.ai/stream/public/<storagePath>, the same URL shape every rendered asset uses). The value is null while queued.

What happens when a run fails? The execution goes to failed with a statusMsg, and the credits are refunded to your balance automatically — you are not billed for a dead job, so an automation can retry without double-charging you.

Can I call it from the browser? Not directly with your secret — the client_secret must stay server-side. Call the API from your backend or a worker and hand your front-end the finished file, not the key.

Is it the same account as the app? Yes. The key belongs to your account, the runs draw from the same balance as the studio, and the Project Director and studio projects are the same account behind it.

Where do I read the exact schema? The Swagger UI and OpenAPI spec at api.moosky.ai/docs are generated from the live routes — read the parameter you are unsure about there rather than trusting any blog, including this one.

Ready to wire it up? Create a key and run the first four calls from the AI Video Generation API page — the estimate endpoint quotes every run before it touches your balance.