Train a custom avatar from video
Turn footage of a person into an avatar that can hold conversations.
A custom avatar is trained from video of a real person. Once training completes, it behaves exactly like a stock avatar — same conversation flow, same knowledge bank, same API.
Every request needs your API key. Set it once:
export GOLDENENGINE_API_KEY="<YOUR_API_KEY>"
Before you record
Training quality is set by the footage. Re-recording after a failed run costs far more time than getting the shot right the first time.
Accepted formats: .mp4, .mov, .webm, .mkv, .avi, and .m4v — or any file sent
with a video/* content type. Uploads are capped at 2 GB; a larger file is rejected with
413 and the code file_too_large. The API checks nothing else about the footage — there is
no resolution check, so problems with it only surface in training.
Training videos can be at most 15 minutes long. The length is checked when training
starts, before any GPU time is spent, so an upload that is too long is accepted and the avatar
then moves to failed with an error_message such as "Video is 18.2 minutes long; the maximum
for training is 15 minutes. Upload a shorter video." A video whose length cannot be read —
some browser MediaRecorder WebM files carry no duration — is trained without the check.
1. Upload the video
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/videos/upload-url" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
import os
import requests
BASE = "https://backend.goldenengine.ai"
HEADERS = {"X-Api-Key": os.environ["GOLDENENGINE_API_KEY"]}
with open("presenter.mp4", "rb") as video:
created = requests.post(
f"{BASE}/v1/videos/upload-url", headers=HEADERS, files={"file": video}
).json()
video_id = created["id"]
const BASE = "https://backend.goldenengine.ai";
const headers = { "X-Api-Key": process.env.GOLDENENGINE_API_KEY };
import { readFile } from "node:fs/promises";
const form = new FormData();
form.set(
"file",
new Blob([await readFile("presenter.mp4")], { type: "video/mp4" }),
"presenter.mp4",
);
const created = await (
await fetch(`${BASE}/v1/videos/upload-url`, { method: "POST", headers, body: form })
).json();
const videoId = created.id;
Take id from the response and keep it for the next step:
export VIDEO_ID="<id from the response>"
Confirm it landed before continuing:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/videos/$VIDEO_ID" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
print(requests.get(f"{BASE}/v1/videos/{video_id}", headers=HEADERS).json())
console.log(await (await fetch(`${BASE}/v1/videos/${videoId}`, { headers })).json());
The upload call returns as soon as the API has the file, before it has finished moving
to storage, so the record usually comes back as pending or uploading. Poll until
status is uploaded — GET /v1/videos/{video_id}/progress is the cheap way, and also
reports upload_progress_percent:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/videos/$VIDEO_ID/progress" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
import time
while True:
progress = requests.get(
f"{BASE}/v1/videos/{video_id}/progress", headers=HEADERS
).json()
if progress["status"] == "uploaded":
break
if progress["status"] == "failed":
raise RuntimeError("Video upload failed; upload it again")
time.sleep(5)
while (true) {
const progress = await (
await fetch(`${BASE}/v1/videos/${videoId}/progress`, { headers })
).json();
if (progress.status === "uploaded") break;
if (progress.status === "failed") throw new Error("Video upload failed; upload it again");
await new Promise((resolve) => setTimeout(resolve, 5000));
}
Creating the avatar before then fails with 400 and "Video not found in S3. Please upload
the video before creating an avatar." — and can leave the video showing failed until the
transfer finishes, which is one more reason to wait. GET /v1/videos lists everything you
have uploaded.
2. Create the avatar
Creating an avatar with a video_id starts training automatically — there is no
separate "begin training" call.
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Dr. Chen",
"bio": "Senior product specialist at Acme, 10 years in medical devices.",
"video_id": "'"$VIDEO_ID"'",
"primary_language": "English (US)",
"llm_model": "gpt-4o",
"tts_provider": "cartesia",
"voice_id": "<VOICE_ID>",
"stt_engine": "deepgram"
}'
avatar = requests.post(
f"{BASE}/v1/avatars",
headers=HEADERS,
json={
"name": "Dr. Chen",
"bio": "Senior product specialist at Acme, 10 years in medical devices.",
"video_id": video_id,
"primary_language": "English (US)",
"llm_model": "gpt-4o",
"tts_provider": "cartesia",
"voice_id": "<VOICE_ID>",
"stt_engine": "deepgram",
},
).json()
avatar_id = avatar["id"]
const avatar = await (
await fetch(`${BASE}/v1/avatars`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
name: "Dr. Chen",
bio: "Senior product specialist at Acme, 10 years in medical devices.",
video_id: videoId,
primary_language: "English (US)",
llm_model: "gpt-4o",
tts_provider: "cartesia",
voice_id: "<VOICE_ID>",
stt_engine: "deepgram",
}),
})
).json();
const avatarId = avatar.id;
Take id from the response — that is your avatar:
export AVATAR_ID="<id from the response>"
name, bio, and video_id are required; everything else falls back to defaults. See
Models for engine and voice values; the accepted persona field
values are listed on the request body in the
API reference.
If the video is missing (404), not fully uploaded (400), or the request references
values outside the allowed option lists (422), creation fails before any training is
queued. Creating an avatar also writes its system prompt from the persona fields through a
model call; if that call fails you get a 502 and no avatar, and can simply retry.
voice_id is stored as sent — the API does not check it against tts_provider, so a
mistyped or mismatched voice is not caught at creation. Copy it from GET /v1/models
rather than typing it.
3. Monitor training
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/status" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
print(requests.get(f"{BASE}/v1/avatars/{avatar_id}/status", headers=HEADERS).json())
console.log(
await (await fetch(`${BASE}/v1/avatars/${avatarId}/status`, { headers })).json(),
);
/status returns the avatar's status, a progress_percent for the current training
run, and error_message once something has gone wrong. The avatar moves through:
pending → queued → training → ready
│ │ │
└─────────┴─────────┴──→ failed
failed can come from any of those steps, not only from training itself. If the training
job cannot be queued right after you create the avatar, it goes straight to failed with
"Training could not be queued (job service unavailable). Please retry training." Cancelling
a run also lands it in failed, with the message "Training cancelled by user request."
For the history of every run on the avatar, look at the training jobs:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/training-jobs" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
jobs = requests.get(
f"{BASE}/v1/avatars/{avatar_id}/training-jobs", headers=HEADERS
).json()
for job in jobs["items"]:
print(job["status"], job.get("progress_percent"), job.get("error_message"))
const jobs = await (
await fetch(`${BASE}/v1/avatars/${avatarId}/training-jobs`, { headers })
).json();
for (const job of jobs.items) {
console.log(job.status, job.progress_percent, job.error_message);
}
Training-job status uses its own vocabulary — pending, running, completed, failed,
cancelled. A job reaching completed is what moves the avatar to ready.
Poll on a sensible interval; training takes far longer than a request timeout, so this is a background job in your system, not a blocking wait.
4. Handle failure
When an avatar ends in failed, read error_message on the avatar or its training job.
Most failures trace back to the source video — the subject leaving frame, inconsistent lighting, multiple people visible, or too little usable footage. Re-read the recording guide before re-shooting, since a second run with the same problems fails the same way.
To retry with the same video — this returns 202 and puts the avatar back in the queue, or
409 if a run is still queued or training:
- cURL
- Python
- Node.js
curl -s -X POST "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/retrain" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
print(requests.post(f"{BASE}/v1/avatars/{avatar_id}/retrain", headers=HEADERS).json())
console.log(
await (
await fetch(`${BASE}/v1/avatars/${avatarId}/retrain`, { method: "POST", headers })
).json(),
);
To stop a run in progress — this works only while the avatar is queued or training, and
returns 409 otherwise:
- cURL
- Python
- Node.js
curl -s -X POST "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/cancel" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY"
print(requests.post(f"{BASE}/v1/avatars/{avatar_id}/cancel", headers=HEADERS).json())
console.log(
await (
await fetch(`${BASE}/v1/avatars/${avatarId}/cancel`, { method: "POST", headers })
).json(),
);
Retraining with different footage means uploading a new video and creating a new avatar.
5. Use it
Once ready, the avatar works everywhere a stock avatar does:
- cURL
- Python
- Node.js
curl -s "https://backend.goldenengine.ai/v1/conversations" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"avatar_id": "'"$AVATAR_ID"'", "title": "First run"}'
print(
requests.post(
f"{BASE}/v1/conversations",
headers=HEADERS,
json={"avatar_id": avatar_id, "title": "First run"},
).json()
)
console.log(
await (
await fetch(`${BASE}/v1/conversations`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ avatar_id: avatarId, title: "First run" }),
})
).json(),
);
A session on an avatar the engine does not have loaded waits several seconds for a cold
start. To take that out of the visitor's wait, call
POST /v1/avatars/{avatar_id}/preload when a session is likely — when the visitor opens
the page, say — and poll GET /v1/avatars/{avatar_id}/preload-status until its status
is ready. It is optional: without it the first connection loads the avatar itself.
Attach documents with the knowledge bank, tune the persona
with PATCH /v1/avatars/{avatar_id}, and put the avatar in front of visitors with
Embed an avatar.