Hand-written fetch wrappers against a fast-moving generative media API are where subtle bugs get into client pipelines. Someone mistypes an aspect ratio (4:5 vs 4x5), forgets to pass estimate_only on a dry run, or misreads a nested job status field the Friday before a campaign launch.
You can skip the hand-maintained JSON and generate a typed TypeScript or Python client straight from Mantinea's OpenAPI 3.1 specification (https://app.mantinea.com/api/v1). Once your IDE autocompletes every operation, payload field and error response, ops engineers look things up in the docs far less often.
Details below reflect Mantinea's public developer documentation and 24 November 2026 pricing. Pull the live spec from https://app.mantinea.com/docs or the API and MCP help page before you generate code.
Why an OpenAPI 3.1 spec matters for video ad ops
Mantinea's public API has far more than a single "render video" endpoint. The docs cover dozens of operations: Brand Brain crawls, script and hook generation, talking-actor renders, Hook lab iterations, 182-language translation, resizing, video quality checks, and reviews and approvals.
A machine-readable openapi video api contract helps growth engineering teams in three ways:
- Compile-time parameter checks. Catch invalid aspect ratios (
9:16,1:1,16:9,4:5), missing idempotency keys or wrong field types in TypeScript or Python before a request spends any credits. - Typed
estimate_onlyresponses. Every paid call in Mantinea acceptsestimate_only, and typed models make it easy to pull quoted credit costs into client budget estimators or Slack approval cards. - No guessing on older naming. Mantinea's developer surfaces still use the product's older "Autonomous" name in places, such as the webhook header
X-Autonomous-Signature. Generating from the live OpenAPI 3.1 document means your client uses the exact field and header names the server expects today.
Step 1: download and pin the spec in your repo
Download the OpenAPI 3.1 JSON or YAML document from Mantinea's developer docs and save it locally (for example, specs/mantinea-openapi.json). With the spec in version control, builds are reproducible, and pull requests show when new operations or model parameters appear.
Check three sections of the spec before you run a generator:
components.securitySchemes: the exact auth header and bearer/key format for your scoped key (read, generate or admin).paths: operation IDs and URL paths for starting jobs, batches (up to 50 jobs), long-polling status (up to 50 seconds) and approvals.- Shared parameters / headers: where
estimate_onlyand idempotency keys go.
Step 2: generate a TypeScript client
For Node, Next.js or Cloudflare Workers stacks, OpenAPI 3.1 generators like openapi-typescript (paired with openapi-fetch) produce types directly from the 3.1 schema with no runtime overhead:
npm install --save-dev openapi-typescript
npm install openapi-fetch
npx openapi-typescript ./specs/mantinea-openapi.json -o ./src/lib/mantinea.d.ts
Then wrap createClient in a thin helper that enforces two agency safety rules by default:
- Read a generate or read key from environment variables. Never hardcode keys, and keep admin keys for people doing ops work.
- Require an explicit
idempotencyKeyargument on any wrapper that starts a paid render, and keepestimate_onlyeasy to toggle for pre-flight quotes.
OpenAPI 3.1 supports JSON Schema 2020-12 constructs natively (oneOf, anyOf, and nullable types without the 3.0 quirks), so openapi-typescript handles discriminated job payloads cleanly.
Step 3: generate a Python client
For Python data pipelines, FastAPI backends or feed-to-ad workers, pick a generator with explicit OpenAPI 3.1 support, such as datamodel-code-generator (Pydantic v2 models paired with httpx) or openapi-python-client:
pip install datamodel-code-generator httpx
datamodel-codegen \
--input ./specs/mantinea-openapi.json \
--input-file-type openapi \
--output ./mantinea_models.py \
--output-model-type pydantic_v2.BaseModel
Pydantic models give you strict validation on incoming webhook payloads and API responses, and you keep full control over httpx timeouts. You'll need that for Mantinea's 50-second long-poll status wait, where the client read timeout has to be longer than 50 seconds.
Build three thin wrappers on top of the generated SDK
A generated client is still too low-level for daily agency scripts. Three small helpers keep every automation inside budget:
quote_before_start(payload): clones the payload withestimate_only: true, runs the call (0 credits), checks the returned credit cost against your client budget cap and logs the quote. Mantinea's "Auto" talking-actor route reserves at 40 credits/s even when it settles at 15 credits/s, so check that your balance covers the reserve.start_idempotent(payload, job_record_id): adds a deterministic idempotency key derived from your internal job row ID (never generated inside a retry loop), so a network timeout can't double-bill a 450-credit ($4.50) talking-actor ad. See idempotency keys in the Mantinea API.wait_or_webhook(job_id): uses the spec's long-poll parameter (up to 50s) for synchronous scripts, or registers the job ID with your webhook listener for asynchronous pipelines.
If you'd rather test raw payloads before setting up codegen, start with the curl quickstart.
Keep the spec fresh without breaking production
Once a month, or whenever your team starts using a newly shipped feature, diff specs/mantinea-openapi.json against the live spec on https://app.mantinea.com/docs, regenerate the types, and run TypeScript tsc --noEmit or pytest in CI.
Mantinea includes its full OpenAPI 3.1 API on every plan from Starter ($29/mo, 2,900 credits) to Scale ($499/mo, 55,000 credits), and on the 14-day free trial (1,000 credits, no card). Some tools keep API access for $550/mo tiers or sell it as a separate developer subscription. On Mantinea, a small agency can generate a typed client on day one, test dry runs with estimate_only and build client handoffs without a second software bill.