Media engineering teams and corporate training departments face a severe operational bottleneck when scaling video output: manual project creation in web interfaces like AI Studios is completely unsustainable for generating dozens or hundreds of personalized or fast-breaking videos daily. Whether producing automated financial market briefings, localized news flashes, or individualized employee onboarding modules from database records, teams must transition from browser-based editing to a programmatic rendering pipeline.
The DeepBrain AI REST API (specifically the Odin v3 / v2 backend architecture) enables full programmatic control over virtual avatar models, wardrobe selection, multi-layered scene compositions, text-to-speech (TTS) scripts, and asynchronous video rendering. At 365Finds, our operational assessment is unequivocal: building a direct, headless ingestion-to-rendering bridge is indispensable for enterprise multimedia teams, but executing it reliably requires overcoming three critical design pitfalls: tight JSON schema coupling, ephemeral CDN asset loss, and uncoordinated task polling.
Here is how engineering teams can architect an automated batch rendering system using the DeepBrain AI REST API and structured database scripts.
1. High-Level Architecture: Database to Rendered MP4
A resilient batch rendering pipeline separates raw editorial data from video composition and rendering mechanics. Rather than calling DeepBrain AI directly from database triggers, production systems employ a three-tier decoupled architecture:
- Structured Script Repository (Relational DB): Stores raw script strings, speaker personas, layout template identifiers, wardrobe preferences, background URLs, and render state flags (
PENDING,QUEUED,RENDERING,COMPLETED,FAILED). - Orchestration Worker & Payload Builder: A distributed task queue (e.g., Celery in Python or BullMQ in Node.js) consumes pending database records, resolves avatar/clothing IDs, compiles the complex scene JSON schema, and submits an export request to DeepBrain AI.
- Status Poller & Asset Ingestion Service: Tracks GPU synthesis progress via webhooks and fallback polling, downloads the completed MP4 from the temporary vendor URL, validates file integrity, and archives it to owned object storage (e.g., AWS S3 or Google Cloud Storage).
[ Database Script Updates ]
│
▼
[ Task Queue (BullMQ/Celery) ]
│
▼
[ DeepBrain AI API: POST /editor/project ] ──> Returns projectId
│
├───> [ Webhook Callback / Poller: GET /editor/progress/{id} ]
│
▼
[ Temporary downloadUrl (100% Progress) ]
│
▼
[ Stream Download & ffprobe Verification ]
│
▼
[ Enterprise Object Storage (S3 / CDN) ] ──> Updates DB to COMPLETED
2. API Authentication and Base Endpoints
DeepBrain AI operates regional endpoints with strict separation between global and mainland Chinese infrastructure. Media teams must configure base URLs accordingly:
- Global Base URL:
https://app.aistudios.com(with v2 endpoints available athttps://v2.aistudios.com) - China Regional Base URL:
https://app.aistudios.cn
Authentication requires an active API-enabled subscription (Pro plan or higher). API keys (AppId and UserKey / API Token) are generated via the AI Studios account dashboard under Profile > App Key. Every programmatic request must pass the key in the HTTP request headers:
Authorization: YOUR_DEEPBRAIN_API_KEY
Content-Type: application/json
3. Deconstructing the Scene JSON Payload (Odin v3)
The primary endpoint for creating and exporting programmatic projects is:
POST https://app.aistudios.com/api/odin/v3/editor/project
The request payload accepts top-level metadata, video canvas properties, and an array of scenes. Each scene contains the background specification, layered clips (including the avatar and secondary graphics), and the spoken script data.
Project-Level Parameters
| Key | Type | Required | Description |
|---|---|---|---|
name | String | No | Internal name for the project (defaults to "Default Template") |
orientation | String | No | Canvas orientation: landscape (16:9, 1920x1080) or portrait (9:16, 1080x1920) |
resolution | String | No | Target video resolution: 1080 (default), 720, 480, or 4k |
isExport | Boolean | No | Set to true to immediately trigger video synthesis |
webhookUrl | String | No | HTTPS endpoint to receive completion callback events |
scenes | Array | Yes | Ordered array of scene configurations to be concatenated |
The Critical Script-to-Clip Contract
A frequent point of integration failure is the strict data coupling between scenes[].scripts[] and scenes[].clips[]:
- The avatar spoken text is defined inside
scenes[].scripts[]withmodelIdandclothId. - The visual avatar element is defined inside
scenes[].clips[](withtype: "aiModel"), wheremodel.ai_namerepresents the avatar ID andmodel.emotionrepresents the clothing style ID. - Strict Rule:
scripts[].modelIdMUST matchclips[].model.ai_name, andscripts[].clothIdMUST matchclips[].model.emotion. Any discrepancy causes rendering initialization to fail.
Complete Scene JSON Payload Example
Below is a production-grade payload demonstrating a branded corporate update with a custom background, an AI presenter positioned stage-right, lower-third branding, and speech script:
{
"name": "Daily_Market_Briefing_20261026",
"orientation": "landscape",
"resolution": "1080",
"isExport": true,
"webhookUrl": "https://api.mediaengine.internal/webhooks/deepbrain",
"scenes": [
{
"sceneIdx": 0,
"watermark": false,
"background": {
"id": "bg_finance_desk",
"type": "background",
"source_type": "image",
"source_url": "https://cdn.mediaengine.internal/assets/bg/newsroom_blue.png",
"source_color": "rgb(20,30,50)"
},
"scripts": [
{
"org": "Good morning. Global financial markets opened higher today as technology stocks led early trading gains.",
"isTTS": false,
"tts": null,
"modelId": "M000045058",
"clothId": "BG00002320"
}
],
"clips": [
{
"id": "avatar_presenter",
"type": "aiModel",
"layer": 2,
"top": 140.0,
"left": 620.0,
"width": 680.0,
"height": 2230.0,
"scaleX": 1.0,
"scaleY": 1.0,
"model": {
"ai_name": "M000045058",
"emotion": "BG00002320",
"language": "en",
"source_url": "https://cdn.aistudios.com/ai/ai_mov_thm/tight_ai_mov_thm_M000045058_BG00002320.png"
}
},
{
"id": "lower_third_graphic",
"type": "image",
"layer": 3,
"top": 860.0,
"left": 100.0,
"width": 600.0,
"height": 120.0,
"source_url": "https://cdn.mediaengine.internal/assets/overlays/lower_third_nasdaq.png"
}
]
}
]
}
4. Automating Model, Wardrobe, and Layer Management
To prevent hardcoding model identifiers into business code, media teams should dynamically query the available roster:
- Endpoint:
GET https://app.aistudios.com/api/odin/v3/dropdown/models - Response Elements: Returns JSON records containing
id(e.g.,"M000045058"),label(e.g., presenter name), andavatarType.
Layer Stacking Rules
Clips inside a scene rely on standard Z-index layering defined by the integer layer attribute:
layer: 0– Background layer (managed via thebackgroundobject or full-screenvideoImageclips).layer: 1tolayer: 5– Middle ground, where the AI avatar (aiModel) is typically placed alongside stage elements.layer: 6+– Foreground overlays, including lower-third banners, financial charts (image), section titles (textImage), and logo watermarks.
For multi-scene videos, sequence order is dictated by sceneIdx (0-indexed). The backend sequentially concatenates each rendered scene into a unified MP4 deliverable.
5. Asynchronous Task Orchestration and Polling Strategy
Video synthesis involves compute-intensive 3D neural rendering and lip-sync generation. Renders generally require between 1 and 10 minutes depending on script length, resolution, and cluster load. Media engineering pipelines must never block on HTTP requests.
Initial Job Submission
Submitting the scene payload returns a response confirming job creation:
{
"success": true,
"data": {
"projectId": "658279786cebbf10f29e2c5a"
}
}
Store this projectId immediately in your database record, transitioning the video status to RENDERING.
Progress Monitoring Endpoint
To query the rendering status programmatically:
- Endpoint:
GET https://app.aistudios.com/api/odin/v3/editor/progress/{projectId} - Response format:
When the synthesis finishes,{ "success": true, "data": { "progress": 72.5, "downloadUrl": null } }progressreaches100and the response supplies the temporary file path:{ "success": true, "data": { "progress": 100, "downloadUrl": "https://cdn-studio.aistudios.com/videos/export_658279786cebbf10f29e2c5a.mp4" } }
The 365Finds Recommended Polling Pattern: Hybrid Webhook + Poller
At 365Finds, we strongly advise engineering teams against relying solely on webhooks or solely on aggressive polling:
- Webhook Fragility: Corporate ingress firewalls, gateway timeouts, or worker redeployments can silently drop incoming completion webhooks, leaving database jobs stuck in
RENDERINGindefinitely. - Naive Polling Waste: Polling every 2 to 3 seconds burns rate limits and incurs unnecessary HTTP overhead across hundreds of concurrent jobs.
- The Solution: Implement a Hybrid Webhook with a Dead-Man's Switch Poller. Configure
webhookUrlto receive the instant completion event ({"progress": 100, "download_url": "..."}). Concurrently, run an asynchronous reconciliation job that pollsGET /editor/progress/{projectId}every 45 to 60 seconds only for tasks whose status has remained pending longer than 3 minutes.
6. Secure Asset Ingestion and Production Verification
A frequent operational oversight in early deployments is assuming that DeepBrain AI's downloadUrl is permanent. Vendor CDN URLs are temporary storage buffers and will be purged according to server retention policies.
Ingestion Workflow
- Stream Download Immediately: As soon as
progress == 100is detected, stream the video binary directly into local disk or memory via HTTP pipe without buffering the entire file into application RAM:const res = await fetch(downloadUrl); const fileStream = fs.createWriteStream(`/tmp/renders/${projectId}.mp4`); await streamPipeline(res.body, fileStream); - ffprobe Header Integrity Check: Before updating database states, inspect the file using
ffprobeto verify that the container is intact, the duration matches expected audio bounds, and the video codec is valid H.264/AAC:ffprobe -v error -show_entries format=duration,size -of json /tmp/renders/658279786cebbf10f29e2c5a.mp4 - Persist to Corporate Storage: Upload the verified binary to an internal AWS S3 or Cloudflare R2 bucket configured with long-term archiving and CDN distribution.
- Finalize Database State: Update the internal database row with the persistent asset URL, record the consumed credits reported by the API (
credit), and mark status asCOMPLETED.
7. Operational Best Practices and Engineering Takeaways
| Architecture Layer | Anti-Pattern | 365Finds Recommended Practice |
|---|---|---|
| Payload Generation | Hardcoding absolute pixel coordinates in database rows | Build semantic scene templates (e.g., "stage_right_reporter", "center_anchor") and map raw text dynamically |
| Model Coupling | Mismatching scripts[].modelId and clips[].model.ai_name | Enforce schema validation at the queue worker layer before issuing the POST request |
| Concurrency & Quotas | Bombarding the API with 100 simultaneous export calls | Restrict task queue concurrency to your plan's active rendering capacity (typically 2–5 concurrent jobs) |
| Status Tracking | Synchronous tight-loop polling every 2 seconds | Hybrid approach: primary webhook listener backed by a 60-second reconciliation sweeper |
| Storage Lifecycle | Embedding the vendor's downloadUrl in client applications | Immediately stream into self-hosted S3/GCS buckets; discard vendor URLs post-ingestion |
By structuring the integration around loose template coupling, strict schema verification, and resilient async task handling, media teams can reliably turn database records into hundreds of broadcast-quality avatar videos every single day.
References
- Get started with API | DeepBrain AI DOCS
- Create project and export | DeepBrain AI DOCS
- Check the progress of the project. | DeepBrain AI DOCS
- Webhook | DeepBrain AI DOCS
- Clip Properties | DeepBrain AI DOCS
- Retrieve models | DeepBrain AI DOCS
- Exporting an JSON-based Template | DeepBrain AI DOCS
- DeepBrain AI: AI Video Generator & AI Studios