RTVIClient is a base class that serves as a template for building transport-specific implementations.
For connected use-cases, you must pass a transport instance to the constructor
for your chosen protocol or provider. See Transport for more
information.
If you were looking to use WebRTC as a transport layer, you may use a provider like Daily. In this scenario, you’d construct a transport instance and pass it to the client accordingly:
Copy
import { RTVIClient } from "realtime-ai";import { DailyTransport } from "@daily-co/realtime-ai-daily";const dailyTransport = new DailyTransport();const rtviClient = new RTVIClient({ transport: dailyTransport,});
All transport packages (such as DailyTransport) extend from the Transport base class defined in RTVI core.
You can extend this class if you are looking to implement your own or add additional functionality.
Instance of Transport required to connect to your bot service (rtviClient.connect()). Transports define connectivity and state logic that manage the lifecycle of your session.
Transports also define a protocol for message exchange between your client and bot service (such as actions, or generic messages.
If your transport package (e.g.
@daily-co/realtime-ai-daily) exports multiple transports classes, you can
specify which to use here.
Copy
import { RTVIClient } from "realtime-ai";import { DailyTransport } from "@daily-co/realtime-ai-daily";const dailyTransport = new DailyTransport();const rtviClient = new RTVIClient({ transport: dailyTransport,});
Endpoints appended to your client base URL. RTVI will apply defaults if not provided.
Property
Description
connect:string
Developer hosted endpoint that triggers authentication, transport session creation and bot instantiation. Typically returns a valid authentication bundle required to join a session. Defaults to “connect/”.
action:string
Developer hosted endpoint that triggers disconnected action for single-turn operations. Typically implemented as a HTTP Stream or Websocket. Defaults to “action/”.
You should ensure your endpoints have the necessary CORS headers set to allow requests from your client application.
Pipeline RTVI configuration passed to your bot pipeline. Must contain a valid RTVIClientConfigOption[] array.
Client configuration is optional and can be passed directly to the bot via your server-side endpoint (where sensitive information can be provided, such as API keys.)
The service order of your configuration array is important. See configuration.
Time (in milleseconds) to wait for the bot to enter a ready state after
calling connect(). If the timeout period is elapsed, the client will return
a ConnectionTimeoutError error and disconnect from the transport.
Calling rtviClient.connect() will trigger a default fetch query to your baseUrl/connect endpoint. If you need to override this behaviour, you can provide a custom connect handler.
Override the default fetch query called by rtviClient.connect(). If your server-side infrastructure has specific requirements, you can provide custom behaviour here.
params:RTVIClientParams Params provided in client constructor.
timeout:Timeout | undefined Start timeout. You should clear this once your method resolves e.g. clearTimeout(timeout).
abortController:AbortController - Aborting connection via abortController.abort() will reject the inflight request, clear the connection timeout and set the client to an error state.