Skip to main content
Render with background_mode=transparent to get a main video + mask video for compositing onto any background.

Workflow

Render with transparent mode

import requests, time
API_KEY, BASE = "YOUR_API_KEY", "https://apis.viggle.ai"
headers = {"Authorization": f"Bearer {API_KEY}"}

job = requests.post(f"{BASE}/api/render", headers=headers, data={
    "character_id": "char_xxx",
    "scene_id": "scene_xxx",
    "background_mode": "transparent",
}).json()
print(f"Job ID: {job['job_id']}")

Wait and download

Poll until complete, then download the video and mask from the CDN URLs in the status response.
while True:
    status = requests.get(f"{BASE}/api/render/{job['job_id']}").json()
    if status["status"] == "complete":
        print(f"Video: {status['cdn_url']}")
        break
    elif status["status"] == "failed": raise Exception(status.get("error_message"))
    time.sleep(3)

# Download main video
video = requests.get(status["cdn_url"])
open("character.mp4", "wb").write(video.content)

Composite in your editor

  1. Import character.mp4 and the mask video
  2. Place character.mp4 above your background layer
  3. Add the mask as a Track Matte (Luma Matte)
  4. Character composites over your custom background

Complete script

import requests, time

API_KEY, BASE = "YOUR_API_KEY", "https://apis.viggle.ai"
headers = {"Authorization": f"Bearer {API_KEY}"}

job = requests.post(f"{BASE}/api/render", headers=headers, data={
    "character_id": "char_xxx", "scene_id": "scene_xxx",
    "background_mode": "transparent",
}).json()

while True:
    status = requests.get(f"{BASE}/api/render/{job['job_id']}").json()
    if status["status"] == "complete": break
    elif status["status"] == "failed": raise Exception(status.get("error_message"))
    time.sleep(3)

video = requests.get(status["cdn_url"])
open("character.mp4", "wb").write(video.content)
print(f"Saved character.mp4")

Tips

If your editor supports chroma keying, use background_mode=solid with bg_color=0,255,0 instead. Traditional green screen without a separate mask file.