Overview

The RTVIClient is the component you will primarily interface with for interacting with your Daily Bot. This client is part of the RTVI suite of client libraries, all of which follow the same API design detailed below. The purpose of this component is to:

  • Provides a connect() method that handshakes / authenticates with your bot service
  • Configures your bot services
  • Manages your media connections
  • Provides methods, callbacks and events for interfacing with your bot

The RTVIClient works in conjunction with the DailyTransport from the realtime-ai-daily library to enable voice and video communication with the bot. A DailyTransport is required for Daily Bots.

This page provides details on the most common parameters, methods, and callbacks you will use with the RTVIClient along with specific API expectations required for Daily Bots. For full reference material and installation instructions, visit the docs for your corresponding library.

Source Docs

API Reference

Constructor Parameters

baseUrl
string
required

Handshake URL to your hosted endpoint that triggers authentication, transport session creation and bot instantiation.

The RTVIClient will send a JSON POST request to this URL and pass the local configuration (config) as a body param.

The RTVIClient expects this endpoint to return the response from the Daily Bots endpoint to establish the connection. Doing so will then established the connection automatically.

Example:

{
  params: {
    baseUrl: "/api/vi";
  }
}
endpoints
Object <{ [key: string]: string
required

These are your local app’s endpoints that your client will use to connect to the /bots/start endpoint or initiate bot actions. For example, if you’re running a Next.js application, you may have a route.ts that is used to call the /bots/start endpoint at /api/v1/start-bot/route.ts. Given that example, your baseUrl would be /api/v1 and your connect endpoint would be start-bot. The same pattern applies for the actions endpoint.

Example:

{
  params: {
    baseUrl: "/api/v1",
    endpoints: {
      connect: "start-bot",
      actions: "bot-actions"
    }
  }
}
config
Array <RTVIClientConfigOption[]>

Pipeline configuration object for your registered services. Must contain a valid RTVIClientConfig array.

Client config is passed to the bot at startup, and can be overriden in your server-side endpoint (where sensitive information can be provided, such as API keys.)

See configuration.

Example:

{
  params: {
    config: [
      {
        service: "tts",
        options: [
          {
            name: "voice",
            value: "79a125e8-cd45-4c13-8a67-188112f4dd22",
          },
        ],
      },
      {
        service: "llm",
        options: [
          {
            name: "model",
            value: "claude-3-5-sonnet-latest",
          },
          {
            name: "initial_messages",
            value: [
              {
                role: "user",
                content: [
                  {
                    type: "text",
                    text: "You are a pirate.",
                  },
                ],
              },
            ],
          },
          {
            name: "run_on_config",
            value: true,
          },
        ],
      },
    ],
  }
}
requestData
Object

Pass through custom request body parameters to your defined connect endpoint.

Example:

{
  params: {
    requestData: {
      services: {
        tts: "cartesia",
        llm: "anthropic"
      }
    }
  }
}

Note: services is intended to be set on the server-side. If you have a need to pass them from the client-side, you can use params.requestData.

callbacks
{ callback:()=>void }

An array of callback functions. See callbacks.

enableMic
boolean
default: "true"

Enable user’s local microphone device.

enableCamera
boolean
default: "false"

Enable user’s local webcam device.

headers
Object <{ [key: string]: string }>

Custom HTTP headers to include in the initial connect web request to the baseUrl.

Example Code