Skip to main content

Embed an avatar

Mint a conversation URL on your server and iframe it into your page.

By the end of this page a visitor to your site can hold a live conversation with your avatar, inside an iframe you control.

The flow has two halves, and the split matters: your server creates the conversation and gets back a short-lived URL, and your page renders that URL in an iframe. The API key never reaches the browser.

You need an avatar whose status is ready and an API key. If you have neither yet, start with the Quickstart.

  1. Mint a conversation URL on your server

    POST /v1/conversations returns conversation_url — a page that renders the live avatar session and is meant to be iframed.

    cURL
    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"'",
    "end_user_id": "user-8f3a",
    "title": "Product demo",
    "greeting": "Hi there, what would you like to know?"
    }'
    {
    "conversation_id": "3f8b1c02-7d4e-4a19-b0c3-5e6f7a8b9c0d",
    "end_user_id": "user-8f3a",
    "conversation_url": "https://www.goldenengine.ai/embed/c/3f8b1c02-7d4e-4a19-b0c3-5e6f7a8b9c0d?token=eyJhbGci...",
    "status": "active",
    "expires_at": "2026-08-18T16:42:00Z"
    }

    avatar_id is the only required field. end_user_id is your own ID for the signed-in visitor: their conversations with this avatar share memory, so the avatar can pick up where it left off with that person. Leave it out for an anonymous visitor and the session starts with no memory and leaves none behind — see Memory and end users. greeting is what the avatar says first. title is shown to the visitor as the avatar's name while the session connects, so set it to the name they should see — left out, it defaults to the avatar's name followed by the date and time.

  2. Render it in an iframe

    Pass conversation_url to your page and use it as the iframe src. Grant these allow entries:

    • microphone — required. The session captures the visitor's speech. Without it the avatar never hears anything.
    • autoplay — required. The avatar's video and audio start on their own once connected.
    • camera — the embed turns the visitor's camera on when they press Start, shows it as a picture-in-picture preview, and sends a still frame to the avatar's language model about a second later and then every 10 seconds, so the avatar can see what the visitor shows it. Without camera the browser refuses the camera, the visitor sees a "could not access camera" notice, and the conversation carries on without it. The visitor can switch the camera off from the preview or the control bar; hide_controls hides the control bar but does not stop the capture. The avatar can only use the frames if its language model accepts images — see Models and voices.
    • fullscreen — lets the control bar's fullscreen button take the embed truly fullscreen. Without it the button falls back to filling the iframe.
    HTML
    <iframe
    src="https://www.goldenengine.ai/embed/c/3f8b1c02-...?token=eyJhbGci..."
    allow="microphone; camera; autoplay; fullscreen"
    style="width: 100%; height: 640px; border: 0;"
    title="Talk to our product specialist"
    ></iframe>

    Size the iframe from your own CSS — the embed fills whatever box you give it.

    Beyond token, the URL takes these parameters:

    ParameterValueEffect
    themedark (default) or lightColour scheme for the screens around the session — the start overlay, the error screens and the ended screen.
    hide_controlstrueHides the entire control bar: mute, captions, fullscreen, camera and end-session. The conversation still runs; the visitor just cannot steer it.
    thumbnail_urlAn image URLShown on the loading screen while the avatar warms up. Used only as a fallback, when the conversation itself carries no thumbnail.
    show_statustrueAdds a status pill at the top right that says what the avatar is doing — listening, thinking, speaking. Hidden by default.
    show_timerfalseHides the elapsed-time clock at the top left. Shown by default, once the session is connected.
    show_resolutionfalseHides the video-quality badge at the top right. Shown by default, once the session is connected. It shows the current video quality, such as 540p, and turns amber while the quality is below the top step. It reads Auto until the engine reports a size.
    show_livetrueAdds a connectivity badge at the top left: green Live, amber Connecting, red Offline. Hidden by default.
    show_signalfalseHides the network signal bars at the top right. Shown by default, once the session is connected. The bars show round-trip time to the engine, not the video quality.

    The five show_* switches take the literal words true or false; any other value leaves the default in place. They are overlays on the video, independent of hide_controls, which only affects the control bar.

    Append them to conversation_url rather than rebuilding it — the token parameter has to survive intact.

    <iframe
    src="https://www.goldenengine.ai/embed/c/3f8b1c02-...?token=eyJhbGci...&theme=light&hide_controls=true&show_timer=false&show_live=true"
    allow="microphone; camera; autoplay; fullscreen"
    style="width: 100%; height: 640px; border: 0;"
    title="Talk to our product specialist"
    ></iframe>
  3. Let the visitor start the session

    The embed opens on its own Ready to talk? screen with a Start Session button. Nothing connects, and the browser asks for no microphone or camera access, until the visitor presses it — that click is the user gesture browsers require for microphone access and unmuted audio. You can render the iframe on page load.

    Mounting it behind a button of your own is optional. It is worth doing when you would rather not create a conversation, or load the embed, for visitors who never open it:

    React
    import { useState } from "react";

    export function StartSession({ getConversationUrl }) {
    const [conversationUrl, setConversationUrl] = useState(null);

    if (!conversationUrl) {
    return (
    <button onClick={async () => setConversationUrl(await getConversationUrl())}>
    Talk to our avatar
    </button>
    );
    }

    return (
    <iframe
    src={conversationUrl}
    allow="microphone; camera; autoplay; fullscreen"
    style={{ width: "100%", height: 640, border: 0 }}
    title="Talk to our product specialist"
    />
    );
    }

    Here getConversationUrl calls your own server, which creates the conversation and returns conversation_url.

  4. Close the session and read it back

    Close the conversation from your server when the visitor leaves. The embed's own end button stops the session but does not close the conversation over the API, so ended_at stays null until you call PATCH. Closing sets the end time and queues the conversation for memory; if nobody closes it, memory is still written once the session has disconnected or been quiet for about 15 minutes. The transcript and recording are available over REST:

    cURL
    CID="3f8b1c02-7d4e-4a19-b0c3-5e6f7a8b9c0d"

    curl -s -X PATCH "https://backend.goldenengine.ai/v1/conversations/$CID" \
    -H "X-Api-Key: $GOLDENENGINE_API_KEY"

    curl -s "https://backend.goldenengine.ai/v1/conversations/$CID/transcript" \
    -H "X-Api-Key: $GOLDENENGINE_API_KEY"

    GET /v1/conversations/{id}/recording returns a download url and the seconds until it expires. recording_status on the conversation tells you whether the recording is ready yet.

The URL is short-lived​

The token inside conversation_url is valid for 60 minutes, and expires_at tells you exactly when. Treat the URL as single-use:

  • Mint one per visitor, at the moment they ask to start. Do not cache it, put it in a build artifact, or share it between visitors.
  • Do not email or link it — it may have lapsed by the time it is opened, and it works for whoever opens it.
  • If a visitor takes longer than 60 minutes to press Start, create another conversation. There is no refresh endpoint.

Anyone holding the URL can join that conversation until the token expires, so hand it to one browser and no further.

What to do next​