Voice AI Avatar API
for Any Website
Integrate a full voice persona with sub-150ms lipsync and universal web tool calling into Webflow, Shopify, WordPress, Framer, React, or custom web apps in 60 seconds.
Quick Start (60 Seconds)
Adding Smara to your site requires no backend setup or complex npm builds. A single <script> tag initializes the voice widget, loads your active knowledge base, and binds page tool actions.
Generate Your API Key
Open your Studio Dashboard to generate a self-serve API key instantly in 1 click, or use sk_live_smara2026 for testing.
Paste Script Tag on Your Site
Insert this single script tag into your site's header or custom HTML block before the closing </body> tag:
<!-- Smara Voice AI Avatar Widget --> <script src="https://smara.space/embed.js" data-api-key="sk_live_smara2026" data-position="bottom-right" data-theme="dark" ></script>
Live Avatar Persona Ready
A floating avatar widget appears on your site. Visitors click to speak, and your AI assistant responds with realistic lipsync and executes page navigation, search, or cart actions.
Platform Embedding Guide
Smara embeds seamlessly into any CMS, website builder, or web application without plugins:
| Platform | Integration Path | Setup Time |
|---|---|---|
| Webflow | Go to Project Settings > Custom Code > Footer Code, paste tag, publish. |
30 seconds |
| Shopify | Go to Online Store > Themes > Edit Code > theme.liquid, paste tag before </body>. |
45 seconds |
| WordPress | Paste in Header & Footer Scripts plugin or in theme's footer.php. |
60 seconds |
| Framer | Go to Site Settings > General > Custom Code > End of <body>. |
30 seconds |
| React / Next.js | Use Next.js <Script src="https://smara.space/embed.js" data-api-key="..." /> component. |
45 seconds |
API Keys & Authentication
Smara uses API keys to authenticate requests and load your configured avatar persona. You can manage and regenerate your API keys anytime inside your Studio Dashboard.
Enterprise Security Model (Session Tokens)
For production applications, follow the Anam AI & HeyGen Security Architecture below. Instead of exposing secret API keys on public websites, generate short-lived ephemeral session tokens from your backend server!
Client Session Tokens (Production)
To prevent API key theft, generate a short-lived session token (valid for 1 hour) on your backend server and pass it to the frontend script using data-session-token:
// Server-side Session Token Generator (Node.js / Express) const express = require('express'); const app = express(); app.post('/api/create-avatar-session', async (req, res) => { const response = await fetch('https://api.smara.space/v1/sessions', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.SMARA_SECRET_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ site_id: 'demo', user_id: req.user ? req.user.id : 'guest_anon', ttl: 3600 // 1 hour TTL }) }); const data = await response.json(); res.json({ session_token: data.session_token }); });
Then initialize the widget on the frontend using the ephemeral session token:
<script src="https://smara.space/embed.js" data-session-token="st_live_9a87f2bc31a4" data-position="bottom-right" ></script>
Domain Security & CORS Restrictions
To prevent unauthorized sites from embedding your avatar widget or consuming your monthly quota, configure Allowed Origin Domains in your Studio Dashboard.
Strict Domain Origin Matching
When Domain Origin Matching is enabled, Smara's WebSocket servers verify the incoming Origin HTTP header against your domain allowlist. Any connection attempt from an unlisted domain is immediately closed with HTTP 403 Forbidden.
| Domain Pattern | Example Allowed Site | Description |
|---|---|---|
https://mybrand.com |
https://mybrand.com |
Exact matching for single production domain |
https://*.webflow.io |
https://staging.webflow.io |
Wildcard matching for Webflow development staging subdomains |
http://localhost:8000 |
http://localhost:8000 |
Local developer environment testing |
Content Security Policy (CSP) Directives
If your web application enforces a strict Content Security Policy, add the following CSP directives to allow Smara script execution and WebRTC audio streaming:
Content-Security-Policy: script-src 'self' https://smara.space https://cdn.smara.space; connect-src 'self' wss://api.smara.space https://api.smara.space; media-src 'self' blob:;
Widget Configuration Attributes
Customize the floating widget appearance and behavior directly via HTML attributes:
| Attribute | Default | Description |
|---|---|---|
data-api-key |
— | Your live API key (or use data-session-token for production) |
data-position |
bottom-right |
Widget position: bottom-right, bottom-left, top-right, top-left |
data-theme |
dark |
Widget theme: dark (#0F0F14) or light (#FFFFFF) |
data-accent-color |
#FF6200 |
Brand color for FAB button, mic highlights, and speech bubbles |
data-size |
64 |
Floating Action Button (FAB) diameter in pixels |
data-brand-name |
Smara AI |
Persona header name displayed inside the chat window |
Universal Web Tool Actions
Smara avatars are trained to execute real-time tool actions directly on your website via voice commands:
| Action Name | Description | Example Voice Command |
|---|---|---|
navigate_page |
Scrolls or redirects visitor to target section/URL | "Take me to your pricing plans." |
open_contact_modal |
Opens lead booking form or callback modal | "I want to book a consultation." |
search |
Executes site-wide keyword search query | "Search for travel backpacks." |
change_theme |
Toggles light mode or dark mode visually | "Switch to dark mode." |
add_to_cart |
Adds item or service plan tier to cart | "Add the Pro Plan to my order." |
checkout |
Triggers instant checkout modal | "Open checkout." |
JavaScript Event Listener Callback
Listen for live tool actions executed by your avatar on your frontend using the native smara:tool_call event:
// Listen for avatar tool call actions on your page window.addEventListener('smara:tool_call', (e) => { const { action, args } = e.detail; console.log('Avatar executed action:', action, args); if (action === 'navigate_page') { document.querySelector(args.target_section)?.scrollIntoView({ behavior: 'smooth' }); } if (action === 'open_contact_modal') { openLeadForm(); } if (action === 'add_to_cart') { myCart.add(args.product_key); } });