Website widget

Add a floating, talking avatar to any website with one script tag: the floating widget or the chat widget, every option, React and Next.js, and your own persona and model with no server.

5 min bitHuman cloud In the browser (WebGPU)

What you’ll build

A talking avatar in the corner of your website. Visitors open it, allow the microphone and talk to it; it answers out loud with its lips in sync. One script tag adds it to any page, in any framework. There is no npm package and no server to run.

You need:

  • a website you can add a <script> tag to, served over HTTPS (or http://localhost while you build);
  • an agent code: A23WJF0199 (the wise-pup sample) or your own agent’s.

Steps

5 steps

  1. Pick the agent

    Use the wise-pup sample (agent code A23WJF0199) while you build. For your own agent, keep Anonymous Share on in its sharing settings: the widgets open the agent’s public link, and its sessions bill your account.

    Expected

    https://bithuman.ai/A23WJF0199 opens the avatar in a browser tab.

  2. Add the floating widget

    Paste this before </body>:

    <script src="https://www.bithuman.ai/widgets/bithuman-gadget.js"></script>
    <script>
      BitHumanGadget.init({
        agentUrl: "https://bithuman.ai/A23WJF0199?deployment=gadget",
        position: "bottom-right",
        buttonText: "Talk to us",
      });
    </script>
    Expected

    A button in the bottom-right corner. Select it: the avatar opens in a floating frame you can drag and resize, asks for the microphone, and answers when you speak.

  3. Or add the chat widget

    The chat widget opens a side panel where visitors type, talk, or switch to video:

    <script src="https://www.bithuman.ai/widgets/bithuman-chat-widget.js"></script>
    <script>
      BitHumanChat.init({
        agentUrl: "https://bithuman.ai/A23WJF0199",
        defaultChatMode: "text",
        welcomeMessage: "Hi! How can I help?",
      });
    </script>
    Expected

    A floating card in the corner. Opening it shows the panel with the welcome message; the mode switch moves between text, voice and video.

  4. Load it in React or Next.js

    In Next.js, load the script with next/script and call init when it has loaded:

    "use client";
    import Script from "next/script";
    
    declare global {
      interface Window { BitHumanGadget?: { init: (options: Record<string, unknown>) => void } }
    }
    
    export function AvatarWidget({ code }: { code: string }) {
      return (
        <Script
          src="https://www.bithuman.ai/widgets/bithuman-gadget.js"
          strategy="afterInteractive"
          onLoad={() => window.BitHumanGadget?.init({ agentUrl: `https://bithuman.ai/${code}?deployment=gadget` })}
        />
      );
    }

    Render <AvatarWidget code="A23WJF0199" /> once, in your root layout. In other React apps, add the two <script> tags to the page’s HTML, or put the web embed in an <iframe> (Web).

    Expected

    The widget's button appears on every page of the app. A second init call is ignored, so a re-render does not add a second widget.

  5. Give it your persona and model

    The widget runs the agent’s managed conversation, so the persona and the model are settings on the agent, not code on your page. Set the persona as the agent’s system_prompt (Persona). To answer with your own model, connect any OpenAI-compatible endpoint with Providers and point the agent’s llm at it.

    Expected

    The next session answers in the new persona, with your model. Nothing on your page changed.

How it works

YOUR APP OR SITEA browser or appsends the microphone, shows the avatarBITHUMAN CLOUD · USThe avatar rendersThe conversation runsbitHuman's voice service, or the provider keysyou connectmicrophoneaudiovideo and voiceYour API secret stays on your server; browsers getscoped embed tokens.
bitHuman cloud. In the bitHuman cloud the avatar renders on bitHuman's servers, in the US, and the conversation runs on bitHuman's voice service or with the provider keys you connect. The browser or app sends the microphone and shows the video. Your API secret stays on your server; browsers get scoped embed tokens.

The script adds a button to your page. Opening it loads the web embed for your agent in a frame. The avatar renders in the bitHuman cloud, in the US, and streams to the visitor. With the web embed, the conversation runs on bitHuman’s servers, even when the avatar renders in the tab.

4 credits per minute of active session time for Essence 2 and Expression 2, about $0.04 a minute at the top-up rate of $1 = 100 credits. A managed agent's voice chat bills 10 credits per minute, all-inclusive: the avatar is part of it. Realtime usage bills active session time, talking or idle, to the second. Every rate: Pricing and credits.

Make it your own

The embed dialog in the bitHuman app writes these options for you. agentUrl is required; the rest are optional.

Floating widget (BitHumanGadget.init):

OptionValues
agentUrlhttps://bithuman.ai/<agent code>?deployment=gadget
themelight (default) or dark
positionbottom-right (default), bottom-left, top-right, top-left, center
sizethe frame’s starting size in pixels (default 200)
transparenttrue removes a green-screen backdrop, so the avatar stands on your page
keyColor, keySimilarity, keySmoothness, keySpill, keyErodefine-tune transparent: the key color, such as 00ff00 (default: sampled from the video), and the edge settings
buttonStylepill (default; image and text), circle, square
buttonTextthe button label, for pill (default “Chat”)
imageUrlthe button’s image (default: the bitHuman logo)
frameStylerounded (default), circular, portrait (9:16)
draggable, resizabletrue (default) or false
minSize, maxSizesize limits in pixels (defaults 50 and 400)
margindistance from the screen edge in pixels (default 60)
autoLoadtrue opens the avatar when the page loads (default false)
greetingLanguageauto (default; from the page’s <html lang>) or a code such as es
greetingMessagethe first thing the avatar says

Chat widget (BitHumanChat.init):

OptionValues
agentUrlhttps://bithuman.ai/<agent code>
themelight (default) or dark
themeColorblue (default), purple, green, red, orange, teal, pink, indigo
positionbottom-right (default) or bottom-left
fabStylepreview (default; a card with the avatar), bar, circle
fabText, fabSubtextthe button’s label and the line under it
fabSizethe circle’s diameter in pixels (default 60)
imageUrlthe image on the button (default: the bitHuman logo)
attentionPulsetrue (default) pulses rings around the avatar
topBanner, topBannerText, topBannerQuestionsa banner across the top of the page, its headline and its question chips
defaultChatModetext (default), voice, video
allowModeSwitchtrue (default) lets visitors switch modes
autoLoadtrue opens the panel when the page loads (default false)
headerTitlethe panel title (default: the agent’s name)
welcomeMessagethe first message in the panel
suggestedQuestionsstarter questions in the panel
teaserEnabled, teaserMessage, teaserDelay, teaserAutoHidea bubble shown after a delay and hidden again, in milliseconds (default on, 2200, 12000)
expandedWidththe panel’s width on a desktop, in pixels (default 420)
margin, zIndexdistance from the edge in pixels (default 20), and stacking order (default 99999)
greetingLanguage, greetingMessageas for the floating widget

For a private agent, or your own layout, use the web embed in an <iframe> with an embed token instead (Web).

Troubleshooting

SymptomFix
Nothing appears, and the browser console says agentUrl is requiredPass agentUrl to init.
The microphone never activatesServe the page over HTTPS, or http://localhost while you build.
The frame shows Embedding is disabled for this agentTurn Anonymous Share back on in the agent’s sharing settings.
The frame shows a browser error pageRemove the Cross-Origin-Embedder-Policy header from your page.
The console says the widget is already initializedCall init once per page.