AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Integrating DeepBrain AI REST API for Automated Batch Avatar Video Rendering

Lucía Bermejo Casado · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

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:

  1. 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).
  2. 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.
  3. 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:

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

KeyTypeRequiredDescription
nameStringNoInternal name for the project (defaults to "Default Template")
orientationStringNoCanvas orientation: landscape (16:9, 1920x1080) or portrait (9:16, 1080x1920)
resolutionStringNoTarget video resolution: 1080 (default), 720, 480, or 4k
isExportBooleanNoSet to true to immediately trigger video synthesis
webhookUrlStringNoHTTPS endpoint to receive completion callback events
scenesArrayYesOrdered 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[]:

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:

Layer Stacking Rules

Clips inside a scene rely on standard Z-index layering defined by the integer layer attribute:

  1. layer: 0 – Background layer (managed via the background object or full-screen videoImage clips).
  2. layer: 1 to layer: 5 – Middle ground, where the AI avatar (aiModel) is typically placed alongside stage elements.
  3. 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:

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:


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

  1. Stream Download Immediately: As soon as progress == 100 is 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);
    
  2. ffprobe Header Integrity Check: Before updating database states, inspect the file using ffprobe to 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
    
  3. 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.
  4. 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 as COMPLETED.

7. Operational Best Practices and Engineering Takeaways

Architecture LayerAnti-Pattern365Finds Recommended Practice
Payload GenerationHardcoding absolute pixel coordinates in database rowsBuild semantic scene templates (e.g., "stage_right_reporter", "center_anchor") and map raw text dynamically
Model CouplingMismatching scripts[].modelId and clips[].model.ai_nameEnforce schema validation at the queue worker layer before issuing the POST request
Concurrency & QuotasBombarding the API with 100 simultaneous export callsRestrict task queue concurrency to your plan's active rendering capacity (typically 2–5 concurrent jobs)
Status TrackingSynchronous tight-loop polling every 2 secondsHybrid approach: primary webhook listener backed by a 60-second reconciliation sweeper
Storage LifecycleEmbedding the vendor's downloadUrl in client applicationsImmediately 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