← MyTwinAvatar

Developer API

Your own apps and websites can talk to your avatars, make videos with them and read the leads they collect. Make a key on your Account page and send it with every request. Keep it secret, on your server: anyone with it can use your account's credits.

Authorization: Bearer mta_…

Each key can make 60 requests a minute; your plan's credits and daily limits apply as on the website. Errors come back as {"error": {"message": "…"}} with a 4xx status. The same rules apply as everywhere: avatars say they're an AI, never pose as real people, and follow the crisis protocol.

GET/api/v1/avatars

Your avatars, with their ids.

curl https://mytwinavatar.com/api/v1/avatars -H "Authorization: Bearer $MTA_KEY"

POST/api/v1/avatars/{id}/chat

One reply from the avatar, with its personality, instructions, knowledge and documents. Send the conversation so far (up to the last 20 messages); your app keeps it. With "voice": true, each sentence also comes with a link that returns its spoken audio once ready (poll it: {"state": "pending" | "done", "url"}).

curl https://mytwinavatar.com/api/v1/avatars/a_123/chat \
  -H "Authorization: Bearer $MTA_KEY" -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Do you ship to Canada?"}], "voice": false}'

{"reply": "Yes, we ship to Canada in 5 to 7 days.", "crisis": false, "waking": false, "sources": ["Shipping FAQ.pdf"], "handoff": false, "speech": []}

If waking is true, the avatar is starting up: send the same messages again in a minute. sources names the avatar's documents the reply drew on. handoff is true when the person asked to talk to a human (with leads on, the reply asks for their email): hand them to your team.

POST/api/v1/speech

Any words, spoken in one of our natural stock voices: for your app's own characters, games or lessons. Choose a voice (af_heart, af_aoede, af_kore, af_nova, af_sky, am_michael, am_onyx, am_puck, bm_george and more: the error lists them all). Optional: language, expression (0.25 calm to 0.9 lively) and speed (0.7 to 1.25) and pitch (semitones, -4 to 4: a younger or deeper voice). Up to 2,000 characters; each sentence comes with a link to poll, as with the chat's voice. The voices are made-up voices, never a real person's, and the audio carries an inaudible AI watermark.

curl https://mytwinavatar.com/api/v1/speech \
  -H "Authorization: Bearer $MTA_KEY" -H "Content-Type: application/json" \
  -d '{"text": "Please be seated. Counsel, you may proceed.", "voice": "af_aoede", "expression": 0.35}'

{"ai_generated": true, "speech": [{"text": "Please be seated.", "audio": "https://…"}, …]}

POST/api/v1/speech/warm

Gets the voice engine ready before you need it (when a lesson or scene opens). From cold that takes several minutes: ask again every 30 seconds or so until ready is true, then lines come back in seconds. It stays ready a couple of minutes after the last line. No body; no credits.

curl -X POST https://mytwinavatar.com/api/v1/speech/warm -H "Authorization: Bearer $MTA_KEY"

{"warming": true, "ready": false}

POST/api/v1/videos

Makes a video, as the website does, and starts rendering it. Send a prompt to have the scenes written, or a script for the exact words. Optional: format (video, reel, ad), aspect (9:16, 16:9, 1:1), language, quality (standard, studio), setting, for_kids (true: written for young children with only the avatar on screen; video or reel, never ad). A video has at most 40 scenes: a script that makes more (each scene up to 60 words, 25 in a reel or ad, and a new scene for each new speaker) answers 400 with how much fits, and nothing is made. Without enough credits it answers 402 and the video waits as a plan. When the GPU is starting, it answers 202 with "status": "planning" while the scenes are written, then renders by itself. A video for kids is read by our AI first; if it isn't safe for children, or the AI is still starting, it answers 422 with the reason.

Every talking or narrated scene needs words: a scene with none (or only punctuation, such as “...”) is never rendered or charged. The video waits as a plan and the answer is 422, with "status": "planned" and the first such scene in error.message: “Scene 1 has nothing to say yet: add a line, change it to an action scene, or remove it.” (for a narrated scene: “Scene 1's narrator has nothing to say yet: add the narrator's line, change it to a scene where they walk or do something, or remove it.”). To choose the words yourself, send a script. A scene that only moves (no narrator) may have no words. If the first answer was 202 (planning), the same message appears later on GET /api/v1/videos/{id}, with the video still "planned".

curl https://mytwinavatar.com/api/v1/videos \
  -H "Authorization: Bearer $MTA_KEY" -H "Content-Type: application/json" \
  -d '{"avatar_id": "a_123", "prompt": "A 20 second welcome for new customers of my bakery", "format": "reel"}'

{"id": "v_456", "status": "rendering"}

Your brand kit: send "brand": true to put your logo, colors, caption style and end card (set on the Brand page) on the video. It's off unless you ask, and never on a video for kids. The answer, and GET /api/v1/videos/{id}, say whether the video carries it with "use_brand": true or false. The AI-generated label stays on every frame.

From a document: instead of a prompt, send document_url (a public https web page; its text only) or document_text (with an optional document_name), and the scenes of a short video are written from its key points. A prompt is then an optional note (what to focus on, where, how long). The writer reads up to 12,000 characters: a longer document is cut to its headings and first sentences, and the answer says so with "document": {"shortened": true}. The document is checked like a prompt, and so is every scene written from it; every rule for kids applies. Up to 20 documents an hour per account (429 after that).

curl https://mytwinavatar.com/api/v1/videos \
  -H "Authorization: Bearer $MTA_KEY" -H "Content-Type: application/json" \
  -d '{"avatar_id": "a_123", "document_url": "https://example.com/our-new-menu", "prompt": "A 30 second summary for regulars"}'

{"id": "v_457", "status": "rendering", "document": {"name": "Our new menu", "shortened": false}}

GET/api/v1/videos/{id}

Where the video stands. Each call also moves rendering forward, so poll every 10-20 seconds until status is done. Each scene then has a link to its clip (with sound), in order, valid for 6 hours. The separate final object tracks the combined MP4: wait for its status to be done and fresh to be true. Its download_url requires the same API key. Videos are labeled AI-generated wherever you post them.

curl https://mytwinavatar.com/api/v1/videos/v_456 -H "Authorization: Bearer $MTA_KEY"

{"id": "v_456", "status": "done", "progress": 100, "scenes": [{"line": "…", "status": "done", "clip": "https://…"}], "final": {"status": "done", "fresh": true, "captionTiming": "aligned", "download_url": "https://mytwinavatar.com/api/v1/videos/v_456/final/file"}}

GET/api/v1/videos/{id}/final/file

Download the complete MP4 with your API key. Range requests are supported. An unfinished or outdated file returns 409; another account's video returns 404. Revoking the key also revokes download access.

curl https://mytwinavatar.com/api/v1/videos/v_456/final/file -H "Authorization: Bearer $MTA_KEY" -o video.mp4

GET / POST / DELETE/api/v1/videos/{id}/final

GET checks the export. POST makes it, retries a failed export or remakes it after edits; repeated requests for a current working or finished export reuse it. DELETE stops an export in progress. Composition uses the engine and may incur processing costs. The video must have finished scenes before POST can start.

captionTiming is aligned, mixed, estimated, unknown (older exports) or off. Check caption timing before publishing when it is mixed, estimated or unknown.

GET/api/v1/leads?avatar_id={id}

The follow-up requests visitors left with a published avatar, newest first.

curl "https://mytwinavatar.com/api/v1/leads?avatar_id=a_123" -H "Authorization: Bearer $MTA_KEY"

Webhooks

To get each new lead the moment it's left, add a webhook address on the avatar's page (Your websites and tools).