Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tavus.io/llms.txt

Use this file to discover all available pages before exploring further.

Server

These primitives are not React components — they are server route handlers and small browser-side fetch helpers. Use them to create and end Tavus conversations without bundling your TAVUS_API_KEY into client JS.

Tavus API

The tavus-api module installs a framework-specific server route that creates and ends Tavus conversations on your backend, plus a small browser client that calls that route.
npx @tavus/cvi-ui@latest add tavus-api
The tavus-api module installs a server route that creates and ends Tavus conversations on your backend, plus a small browser client that calls that route. Your TAVUS_API_KEY stays on the server and is never bundled into your client JS.What gets installedThe CLI detects your framework and installs the matching server route:
FrameworkServer route file
Next.js (App Router)app/api/tavus/route.ts
Next.js (Pages Router)pages/api/tavus.ts
Remixapp/routes/api.tavus.ts
TanStack Startapp/routes/api/tavus.ts
Plus the browser-side client at <components-path>/lib/tavus-client.ts, which exports createTavusConversation(params?) and endTavusConversation(id). Both functions POST to /api/tavus; the route forwards params verbatim to the Tavus REST API, so every field on POST /v2/conversations works. New Tavus fields work without a CLI update.Behaviour for unsupported frameworksIf the CLI doesn’t recognise the framework as one with a built-in server (plain Vite, Expo, manual setups), add tavus-api exits with an error rather than silently installing a key-exposing client. See the Vite-with-server opt-in below.Required environment variable (server only — never on the client)

Tavus API for Vite (with a server runtime)

For Vite projects that have a server (Vinxi, Hono, vike-server, custom Express, Bun, Cloudflare Workers, …), add tavus-api-vite-ssr installs a runtime-agnostic Request handler you wire into your middleware.
npx @tavus/cvi-ui@latest add tavus-api-vite-ssr
Installs <components-path>/lib/tavus-api-vite-ssr.ts exporting handleTavusRequest(request: Request): Promise<Response>, plus the matching lib/tavus-client.ts. The handler uses the standard Web Fetch Request/Response interfaces, so it plugs into any server runtime that speaks fetch.Wiring examples (the file header includes these too):
  • Hono:
    import { handleTavusRequest } from './lib/tavus-api-vite-ssr';
    app.post('/api/tavus', (c) => handleTavusRequest(c.req.raw));
    
  • h3 / Vinxi:
    import { eventHandler, toWebRequest } from 'h3';
    import { handleTavusRequest } from './lib/tavus-api-vite-ssr';
    export default eventHandler((event) => handleTavusRequest(toWebRequest(event)));
    
  • Express (with a Web Fetch adapter such as @hattip/adapter-node):
    app.post('/api/tavus', async (req, res) => {
      const webRes = await handleTavusRequest(toWebRequest(req));
      // pipe webRes back to res
    });
    
Once the handler is mounted at POST /api/tavus, the installed lib/tavus-client.ts calls it from the browser — no API key on the client.Required environment variable (server only)TAVUS_API_KEY. Create one in the Tavus Developer Portal.The full create-conversation field surface is supported via createTavusConversation(params) — see the API reference and the tavus-api section above for the params shape.
No client-only mode. We deliberately do not ship a browser-direct client. Calling Tavus directly from the browser would put your API key in the bundle, which is unsafe in any deployed context. If your project has no server, add one (Vinxi, Hono, vike-server, …) and use tavus-api-vite-ssr above.