AI UGC Review
Workflows and teams

Batch Up to 50 Ad Jobs in One API Call: A Developer Tutorial

A batch video generation API tutorial: build a hooks x actors matrix, quote it with estimate_only, then submit and track up to 50 Mantinea jobs per call.

An agency test pack is rarely one ad. It's three hooks times two actors times two ratios, for four clients, every week. Sending those as single calls works until it doesn't: you end up with a script full of loops, retries and half-finished packs. Mantinea's public API accepts up to 50 jobs in one batch call, which turns a test pack into one request you can quote, submit and track as a unit.

This tutorial builds a batch from a creative matrix, prices it first, submits it, and handles results. API facts are from Mantinea's public docs; prices from the 24 November 2026 price list. Paths and field names below are placeholders: generate a client from the OpenAPI 3.1 spec and use its names.

When to batch, and when not to

Batch when the jobs are known up front and independent of each other: every combination of a matrix, every SKU in a drop, every language of an approved master.

Don't batch when step two depends on step one's output (render, then hook test the winner). That's a workflow, and Mantinea's workflows canvas or an agent turn handles dependencies better than your code will.

If the person asking is a strategist rather than a developer, the in-app Variations matrix does the same thing without code, and shows "N x M x K = T creatives, about C credits" before it runs.

Step 1: build the matrix

Start with the creative dimensions, not the API. For one client:

hooks = [
    "I almost returned this. Then I tried it for a week.",
    "Three things nobody tells you about meal prep containers.",
    "Stop buying the cheap ones. Here's why.",
]
actors = ["actor_kitchen_a", "actor_gym_b"]   # ids from your library
ratios = ["9:16"]                               # resize later, it's 1 credit each

jobs = [
    {"script": f"{h} {BODY}", "actor": a, "ratio": r, "seconds": 20}
    for h in hooks for a in actors for r in ratios
]  # 3 x 2 x 1 = 6 jobs

Keep ratios out of the matrix where you can. Rendering 9:16 and then resizing to 1:1 and 16:9 at 1 credit each is far cheaper than rendering each ratio from scratch.

Step 2: give every job an idempotency key

Do this before you quote, so the key travels with the job definition:

import hashlib

for j in jobs:
    digest = hashlib.sha256(j["script"].encode()).hexdigest()[:12]
    j["idempotency_key"] = f"{CLIENT}:{WEEK}:{digest}:{j['actor']}"

Use a stable hash like SHA-256, not Python's built-in hash(), which changes between processes.

If the batch call times out and you resend it, jobs with keys the API has already seen return the original job instead of starting a second paid render. Deterministic keys (built from the job's content) are what make this safe; random keys generated at retry time defeat the purpose. More in idempotency keys in the Mantinea API.

Step 3: quote the whole batch

Send the batch with estimate_only: true first. You get the credit cost before anything starts.

Sanity-check against list prices. Six 20-second talking-actor jobs at 15 credits per second:

  • 6 x 20 x 15 = 1,800 credits, about $18.
  • Captions on each: 6 x 2 = 12 credits.
  • Two resizes each later: 6 x 2 x 1 = 12 credits.

Total about 1,824 credits. If you leave the route on "Auto", note that it reserves at 40 credits per second and you pay for the route that actually ran, so the quote can be higher than the final bill. Pick the route explicitly if your budget check is tight.

Compare the quote to the client's weekly budget in code. If it's over, stop and ask a human.

Step 4: chunk and submit

Fifty is the ceiling per call. For bigger runs, chunk:

def chunks(xs, n=50):
    for i in range(0, len(xs), n):
        yield xs[i:i+n]

for part in chunks(all_jobs):
    resp = api.batch(part)          # generate-scoped key
    record(resp)                    # store job ids against your idempotency keys
    pace()                          # stay under the per-key limits

Rate limits are 600 requests and 60 paid starts per minute per key. Plan as though each job in a batch counts toward paid starts, and pace big runs across minutes. A 180-job run for four clients becomes four chunks spread over a few minutes. Check the docs for how batches count against the limits. API rate limits decoded covers pacing in detail.

A cleaner setup for agencies: one generate key per client. Limits apply per key, and a runaway loop on one client can't starve the others.

Step 5: track results per job, not per batch

A batch is a submission convenience. Each job still succeeds, fails or is canceled on its own. Two ways to follow them:

  • Signed webhooks for job events, retried at 1 min, 5 min, 30 min, 2 h, 6 h and 12 h if you don't acknowledge. Best for pipelines.
  • Long-poll a job for up to 50 seconds per request. Fine for a script you're watching.

Store state per job id. When all six of a client's jobs reach a final state, mark the pack done and move on. Failed or canceled jobs are refunded automatically, so a partial failure costs only the jobs that ran. Resubmit failed ones with their original keys after fixing whatever caused the failure.

Step 6: finish and hand off

When the pack is done:

  1. Burn captions (2 credits each) or apply Brand finish (2 credits per started minute).
  2. Resize the winners' candidates to 1:1 and 16:9.
  3. Open a review for the client through the API. Reviews and approvals are on the public API as well as in the app.

Checklist

  • Matrix built from creative dimensions; ratios resized, not rendered.
  • Deterministic idempotency key per job.
  • Quote with estimate_only before every batch; compare to budget.
  • Chunks of 50 or fewer, paced under per-key limits.
  • Per-job tracking by webhook or long-poll.
  • Review request at the end, so nothing ships unapproved.

The API, batching and webhooks are on every Mantinea plan from $29 a month. The 14-day trial (1,000 credits, no card) is enough to run a small batch end to end before you point it at client work.

The AI UGC Review editors

We review AI UGC ad tools from their own pricing pages, docs and help centers, and we say who each one suits and who should skip it. We work from vendors' own pricing pages, docs and help centers, and date every price we quote. About us.