### Install LiveAvatar Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/liveavatar/README.md Install the LiveAvatar plugin using npm or pnpm. ```bash npm install @livekit/agents-plugin-liveavatar ``` ```bash pnpm add @livekit/agents-plugin-liveavatar ``` -------------------------------- ### Install MiniMax Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/minimax/README.md Install the MiniMax plugin for LiveKit Agents using pnpm. Ensure you have Node.js and pnpm installed. ```bash pnpm add @livekit/agents-plugin-minimax ``` -------------------------------- ### Install LiveKit Agents Core Library Source: https://github.com/livekit/agents-js/blob/main/README.md Install the core Agents library along with any desired plugins using pnpm. This command installs the main package for agent functionality. ```bash pnpm install @livekit/agents ``` -------------------------------- ### Install Runway Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/runway/README.md Install the Runway plugin for LiveKit Agents using npm. ```bash npm install @livekit/agents-plugin-runway ``` -------------------------------- ### Migrate Installation Source: https://github.com/livekit/agents-js/blob/main/plugins/mistral/README.md Install the new package instead of the deprecated one to migrate your project. ```diff - npm install @livekit/agents-plugin-mistral + npm install @livekit/agents-plugin-mistralai ``` -------------------------------- ### Running an Example Agent Source: https://github.com/livekit/agents-js/blob/main/CLAUDE.md Command to build and run a basic example agent. Ensure all environment variables for LiveKit and any required providers are set before execution. ```bash pnpm build && node ./examples/src/basic_agent.ts dev --log-level=debug ``` -------------------------------- ### Multi-Agent Handoff Example Source: https://github.com/livekit/agents-js/blob/main/README.md Demonstrates a multi-agent system where an introductory agent gathers user information and then hands off to a story agent. This setup is useful for complex conversational flows requiring different agent specializations. ```typescript type StoryData = { name?: string; location?: string; }; class IntroAgent extends voice.Agent { constructor() { super({ instructions: `You are a story teller. Your goal is to gather a few pieces of information from the user to make the story personalized and engaging. Ask the user for their name and where they are from.`, tools: { informationGathered: llm.tool({ description: 'Called when the user has provided the information needed to make the story personalized and engaging.', parameters: z.object({ name: z.string().describe('The name of the user'), location: z.string().describe('The location of the user'), }), execute: async ({ name, location }, { ctx }) => { ctx.userData.name = name; ctx.userData.location = location; return llm.handoff({ agent: new StoryAgent(name, location), returns: "Let's start the story!", }); }, }), }, }); } // Use inheritance to create agent with custom hooks async onEnter() { this.session.generateReply({ instructions: '"greet the user and gather information"', }); } } class StoryAgent extends voice.Agent { constructor(name: string, location: string) { super({ instructions: `You are a storyteller. Use the user's information in order to make the story personalized. The user's name is ${name}, from ${location}`, }); } async onEnter() { this.session.generateReply(); } } export default defineAgent({ prewarm: async (proc: JobProcess) => { proc.userData.vad = await silero.VAD.load(); }, entry: async (ctx: JobContext) => { await ctx.connect(); const participant = await ctx.waitForParticipant(); console.log('participant joined: ', participant.identity); const userdata: StoryData = {}; const session = new voice.AgentSession({ vad: ctx.proc.userData.vad! as silero.VAD, stt: new inference.STT({ model: 'deepgram/nova-3', language: 'en' }), llm: new inference.LLM({ model: 'openai/gpt-4.1-mini' }), tts: new inference.TTS({ model: 'cartesia/sonic-3', voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc' }), userData: userdata, }); await session.start({ agent: new IntroAgent(), room: ctx.room, }); }, }); ``` -------------------------------- ### Install Perplexity Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/perplexity/README.md Install the Perplexity plugin for LiveKit Agents using pnpm. ```bash pnpm add @livekit/agents-plugin-perplexity ``` -------------------------------- ### Install Mistral AI Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/mistralai/README.md Install the Mistral AI plugin for LiveKit Agents using npm. ```bash npm install @livekit/agents-plugin-mistralai ``` -------------------------------- ### Install pnpm Source: https://github.com/livekit/agents-js/blob/main/README.md Install pnpm globally using npm if it is not already installed. This is a prerequisite for installing the LiveKit Agents library. ```bash npm install -g pnpm ``` -------------------------------- ### AvatarSession.start Method Source: https://github.com/livekit/agents-js/blob/main/plugins/bey/README.md Starts the avatar session and connects it to a LiveKit room. ```APIDOC ## AvatarSession.start Starts the avatar session and connects it to the room. ### Method `start(agentSession: AgentSession, room: Room, options?: StartOptions): Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Options for `start` method - **livekitUrl** (string) - Optional - The LiveKit server URL. Can also be set via `LIVEKIT_URL` environment variable. - **livekitApiKey** (string) - Optional - Your LiveKit API key. Can also be set via `LIVEKIT_API_KEY` environment variable. - **livekitApiSecret** (string) - Optional - Your LiveKit API secret. Can also be set via `LIVEKIT_API_SECRET` environment variable. ### Request Example ```typescript import { AvatarSession } from '@livekit/agents-plugin-bey'; import { AgentSession } from '@livekit/agents'; const avatarSession = new AvatarSession({ avatarId: 'your-avatar-id', apiKey: process.env.BEY_API_KEY, }); await avatarSession.start(agentSession, room, { livekitUrl: process.env.LIVEKIT_URL, livekitApiKey: process.env.LIVEKIT_API_KEY, livekitApiSecret: process.env.LIVEKIT_API_SECRET, }); ``` ### Response #### Success Response (200) - **void** - Indicates the avatar session has started successfully. #### Response Example (No specific response body for success, the promise resolves to void.) ``` -------------------------------- ### Initialize and Start Avatar Session Source: https://github.com/livekit/agents-js/blob/main/plugins/lemonslice/README.md Demonstrates how to instantiate an AvatarSession with an image URL and start the session within a LiveKit room. ```typescript import { AvatarSession } from '@livekit/agents-plugin-lemonslice'; const avatar = new AvatarSession({ agentImageUrl: 'publicly-accessible-image-url', apiKey: 'your-lemonslice-api-key', extraPayload: { aspect_ratio: '9x16', }, }); await avatar.start(agentSession, room); ``` -------------------------------- ### Install D-ID Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/did/README.md Install the D-ID plugin for LiveKit Agents using npm. ```bash npm install @livekit/agents-plugin-did ``` -------------------------------- ### Start Beyond Presence Avatar Session in LiveKit Agent Source: https://github.com/livekit/agents-js/blob/main/plugins/bey/README.md Demonstrates how to create and start an AvatarSession using the @livekit/agents-plugin-bey. This involves initializing the session with avatar details and LiveKit connection options, then starting it within an AgentSession. ```typescript import { AvatarSession } from '@livekit/agents-plugin-bey'; import { AgentSession } from '@livekit/agents'; // Create an avatar session const avatarSession = new AvatarSession({ avatarId: 'your-avatar-id', // optional, defaults to stock avatar apiKey: process.env.BEY_API_KEY, // optional if set via env var }); // Start the avatar in your agent await avatarSession.start(agentSession, room, { livekitUrl: process.env.LIVEKIT_URL, livekitApiKey: process.env.LIVEKIT_API_KEY, livekitApiSecret: process.env.LIVEKIT_API_SECRET, }); ``` -------------------------------- ### Basic LLM Setup with Google AI Studio Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Initialize the LLM client using an API key from Google AI Studio. Alternatively, set the GOOGLE_API_KEY environment variable. ```typescript import { LLM } from '@livekit/agents-plugin-google'; // Using Google AI Studio (API Key) const llm = new LLM({ model: 'gemini-1.5-flash', apiKey: 'your-api-key', // or set GOOGLE_API_KEY env var }); ``` -------------------------------- ### Install LemonSlice Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/lemonslice/README.md Commands to install the LemonSlice plugin package using common Node.js package managers. ```bash npm install @livekit/agents-plugin-lemonslice pnpm add @livekit/agents-plugin-lemonslice yarn add @livekit/agents-plugin-lemonslice ``` -------------------------------- ### Run Agent Production Mode Source: https://github.com/livekit/agents-js/blob/main/README.md Starts the agent with production-ready optimizations. This command is used for deploying the agent to a production environment. ```bash pnpm run build && node ./examples/src/restaurant_agent.ts start ``` -------------------------------- ### Build Project with pnpm Source: https://github.com/livekit/agents-js/blob/main/README.md Build the project using the pnpm package manager. Ensure pnpm is installed and configured for the project. ```bash pnpm build ``` -------------------------------- ### Install Tavus Plugin Source: https://github.com/livekit/agents-js/blob/main/plugins/tavus/README.md Install the Tavus plugin using npm. This command adds the necessary package to your project. ```bash npm install @livekit/agents-plugin-tavus ``` -------------------------------- ### Basic LLM Setup with Vertex AI Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Initialize the LLM client for Vertex AI, specifying the model, project ID, and location. Alternatively, set GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_CLOUD_PROJECT, and GOOGLE_CLOUD_LOCATION environment variables. ```typescript import { LLM } from '@livekit/agents-plugin-google'; // Using Vertex AI const llm = new LLM({ model: 'gemini-1.5-pro', vertexai: true, project: 'your-project-id', // or set GOOGLE_CLOUD_PROJECT env var location: 'us-central1', // or set GOOGLE_CLOUD_LOCATION env var }); ``` -------------------------------- ### Initialize and Start Avatar Session Source: https://github.com/livekit/agents-js/blob/main/plugins/liveavatar/README.md Initialize an AvatarSession with configuration options and start it with an agent session and room details. Environment variables can be used for fallback configuration. ```typescript import { AvatarSession } from '@livekit/agents-plugin-liveavatar'; import { AgentSession } from '@livekit/agents'; const avatarSession = new AvatarSession({ avatarId: 'your-avatar-id', // or via LIVEAVATAR_AVATAR_ID apiKey: process.env.LIVEAVATAR_API_KEY, videoQuality: 'high', // optional: 'very_high' | 'high' | 'medium' | 'low' }); await avatarSession.start(agentSession, room, { livekitUrl: process.env.LIVEKIT_URL, livekitApiKey: process.env.LIVEKIT_API_KEY, livekitApiSecret: process.env.LIVEKIT_API_SECRET, }); ``` -------------------------------- ### AvatarSession.start Source: https://github.com/livekit/agents-js/blob/main/plugins/liveavatar/README.md Starts the avatar session, establishing a LiveAvatar streaming session and routing audio. ```APIDOC ## AvatarSession.start(agentSession, room, options?) Starts the avatar session, brings up a LiveAvatar streaming session, opens the realtime websocket, and routes the agent's audio output through to the avatar. ### Parameters - **agentSession** - The AgentSession object. - **room** - The LiveKit Room object. - **options** (StartOptions) - Optional configuration for starting the session. #### StartOptions - **livekitUrl** (string) - Optional - Falls back to `LIVEKIT_URL`. - **livekitApiKey** (string) - Optional - Falls back to `LIVEKIT_API_KEY`. - **livekitApiSecret** (string) - Optional - Falls back to `LIVEKIT_API_SECRET`. ``` -------------------------------- ### Install @livekit/agents-plugin-bey Source: https://github.com/livekit/agents-js/blob/main/plugins/bey/README.md Installs the Beyond Presence plugin for LiveKit Agents using npm or pnpm. This package provides the necessary tools to integrate virtual avatars. ```bash npm install @livekit/agents-plugin-bey ``` ```bash pnpm add @livekit/agents-plugin-bey ``` -------------------------------- ### Dockerfile for Pre-downloading Plugin Assets Source: https://github.com/livekit/agents-js/blob/main/CLAUDE.md Example Dockerfile snippet demonstrating how to pre-download plugin assets. This approach caches the download layer separately from application code. ```dockerfile COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile RUN npx livekit-agents download-files COPY src/ ./src RUN pnpm build ``` -------------------------------- ### Define a Voice Agent with Phonic Integration Source: https://github.com/livekit/agents-js/blob/main/plugins/phonic/README.md This example demonstrates how to define a voice agent using the Phonic plugin. It includes setting up LLM tools and configuring the Phonic realtime model with specific voice and audio speed settings. The agent is configured to greet the user and can toggle lights using a defined tool. ```typescript // SPDX-FileCopyrightText: 2026 LiveKit, Inc. // // SPDX-License-Identifier: Apache-2.0 import { type JobContext, ServerOptions, cli, defineAgent, llm, voice } from '@livekit/agents'; import * as phonic from '@livekit/agents-plugin-phonic'; import { fileURLToPath } from 'node:url'; import { z } from 'zod'; const toggleLight = llm.tool({ description: 'Toggle a light on or off. Available lights are A05, A06, A07, and A08.', parameters: z.object({ light_id: z.string().describe('The ID of the light to toggle'), state: z.enum(['on', 'off']).describe('Whether to turn the light on or off'), }), execute: async ({ light_id, state }) => { console.log(`Turning ${state} light ${light_id}`); await new Promise((resolve) => setTimeout(resolve, 1_000)); return `Light ${light_id} turned ${state}`; }, }); export default defineAgent({ entry: async (ctx: JobContext) => { const agent = new voice.Agent({ instructions: 'You are a helpful voice AI assistant named Alex.', tools: { toggle_light: toggleLight, }, }); const session = new voice.AgentSession({ // Uses PHONIC_API_KEY environment variable when apiKey is not provided llm: new phonic.realtime.RealtimeModel({ voice: 'sabrina', audioSpeed: 1.2, }), }); await session.start({ agent, room: ctx.room, }); await ctx.connect(); await session.generateReply({ instructions: 'Greet the user, asking about their day.', }); }, }); cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url) })); ``` -------------------------------- ### Initialize and Start Trugen Avatar Session in TypeScript Source: https://github.com/livekit/agents-js/blob/main/plugins/trugen/README.md Demonstrates how to initialize and start a Trugen avatar session within a LiveKit agent. This involves creating an AvatarSession instance and calling its start method before the agent session begins. It requires LiveKit connection details and optionally a Trugen avatar ID. ```typescript import { AvatarSession } from '@livekit/agents-plugin-trugen'; // inside your existing defineAgent entry function: const avatarSession = new AvatarSession({ avatarId: process.env.TRUGEN_AVATAR_ID, // optional apiKey: process.env.TRUGEN_API_KEY, }); // must be called BEFORE agentSession.start() await avatarSession.start(agentSession, room, { livekitUrl: process.env.LIVEKIT_URL, livekitApiKey: process.env.LIVEKIT_API_KEY, livekitApiSecret: process.env.LIVEKIT_API_SECRET, }); ``` -------------------------------- ### Run Agent Development Mode Source: https://github.com/livekit/agents-js/blob/main/README.md Starts the agent worker in development mode, ready to accept connections. Ensure all required environment variables are set before running. ```bash pnpm run build && node ./examples/src/restaurant_agent.ts dev ``` -------------------------------- ### Install Sarvam AI Plugin for LiveKit Agents Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Installs the Sarvam AI plugin for LiveKit Agents using pnpm. This package provides Text-to-Speech (TTS) and Speech-to-Text (STT) capabilities. ```bash pnpm add @livekit/agents-plugin-sarvam ``` -------------------------------- ### Create Expressive D-ID Agent Source: https://github.com/livekit/agents-js/blob/main/plugins/did/README.md Example of creating an expressive D-ID agent using the D-ID API. Ensure you replace with your actual D-ID API key. ```bash curl -X POST https://api.d-id.com/agents \ -H "Authorization: Basic " \ -H "Content-Type: application/json" \ -d '{ \ "presenter": { \ "type": "expressive", \ "presenter_id": "public_mia_elegant@avt_TJ0Tq5" \ }, \ "preview_name": "My Expressive Agent" \ }' ``` -------------------------------- ### Install Trugen Plugin for LiveKit Agents Source: https://github.com/livekit/agents-js/blob/main/plugins/trugen/README.md Installs the Trugen plugin for LiveKit Agents using npm or pnpm. This package provides the necessary components to integrate Trugen's realtime avatars. ```bash npm install @livekit/agents-plugin-trugen ``` ```bash pnpm add @livekit/agents-plugin-trugen ``` -------------------------------- ### Simple Voice Agent with LiveKit Agents JS Source: https://github.com/livekit/agents-js/blob/main/README.md Defines a simple voice agent using LiveKit Agents JS. This example demonstrates setting up Speech-to-Text (STT), Large Language Model (LLM), Text-to-Speech (TTS), and Voice Activity Detection (VAD). It utilizes the LiveKit Inference Gateway, so no third-party API keys are required. ```typescript import { type JobContext, type JobProcess, WorkerOptions, cli, defineAgent, llm, voice, inference, } from '@livekit/agents'; import * as silero from '@livekit/agents-plugin-silero'; import { fileURLToPath } from 'node:url'; import { z } from 'zod'; const lookupWeather = llm.tool({ description: 'Used to look up weather information.', parameters: z.object({ location: z.string().describe('The location to look up weather information for'), }), execute: async ({ location }, { ctx }) => { return { weather: 'sunny', temperature: 70 }; }, }); export default defineAgent({ prewarm: async (proc: JobProcess) => { proc.userData.vad = await silero.VAD.load(); }, entry: async (ctx: JobContext) => { const agent = new voice.Agent({ instructions: 'You are a friendly voice assistant built by LiveKit.', tools: { lookupWeather }, }); const session = new voice.AgentSession({ // Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand // See all available models at https://docs.livekit.io/agents/models/stt/ stt: new inference.STT({ model: 'deepgram/nova-3', language: 'en' }), // A Large Language Model (LLM) is your agent's brain, processing user input and generating a response // See all available models at https://docs.livekit.io/agents/models/llm/ llm: new inference.LLM({ model: 'openai/gpt-4.1-mini' }), // Text-to-speech (TTS) is your agent's voice, turning the LLM's text into speech that the user can hear // See all available models as well as voice selections at https://docs.livekit.io/agents/models/tts/ tts: new inference.TTS({ model: 'cartesia/sonic-3', voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc' }), // VAD and turn detection are used to determine when the user is speaking and when the agent should respond // See more at https://docs.livekit.io/agents/build/turns vad: ctx.proc.userData.vad! as silero.VAD, turnDetection: new livekit.turnDetector.MultilingualModel(), // to use realtime model, replace the stt, llm, tts and vad with the following // llm: new openai.realtime.RealtimeModel(), }); await session.start({ agent, room: ctx.room, }); await session.generateReply({ instructions: 'greet the user and ask about their day', }); }, }); cli.runApp(new WorkerOptions({ agent: fileURLToPath(import.meta.url) })); ``` -------------------------------- ### Install Cerebras Plugin for LiveKit Agents Source: https://github.com/livekit/agents-js/blob/main/plugins/cerebras/README.md Use this command to add the Cerebras plugin to your LiveKit agents project. ```bash pnpm add @livekit/agents-plugin-cerebras ``` -------------------------------- ### AvatarSession Class Source: https://github.com/livekit/agents-js/blob/main/plugins/trugen/README.md The AvatarSession class is the primary interface for initializing and starting a Trugen avatar session within a LiveKit agent. ```APIDOC ## AvatarSession ### Description Initializes a new Trugen avatar session to be used within a LiveKit agent. ### Constructor Options - **avatarId** (string) - Optional - The specific avatar ID to use. - **apiUrl** (string) - Optional - The Trugen API URL (defaults to https://api.trugen.ai). - **apiKey** (string) - Optional - The Trugen API key. - **avatarParticipantIdentity** (string) - Optional - Identity for the avatar participant (defaults to 'trugen-avatar'). - **avatarParticipantName** (string) - Optional - Display name for the avatar participant (defaults to 'Trugen Avatar'). ### Methods #### start(agentSession, room, options) Starts the avatar session and connects it to the specified LiveKit room. - **agentSession** (Object) - Required - The current agent session instance. - **room** (Object) - Required - The LiveKit room instance. - **options** (Object) - Optional - Connection options including livekitUrl, livekitApiKey, and livekitApiSecret. ### Usage Example ```typescript const avatarSession = new AvatarSession({ avatarId: process.env.TRUGEN_AVATAR_ID, apiKey: process.env.TRUGEN_API_KEY, }); await avatarSession.start(agentSession, room, { livekitUrl: process.env.LIVEKIT_URL, livekitApiKey: process.env.LIVEKIT_API_KEY, livekitApiSecret: process.env.LIVEKIT_API_SECRET, }); ``` ``` -------------------------------- ### Initialize Sarvam AI TTS Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Initializes the Text-to-Speech (TTS) service using Sarvam AI's Bulbul models. Supports specifying speaker, model, and target language. This example uses the default streaming WebSocket path. ```typescript import * as sarvam from '@livekit/agents-plugin-sarvam'; const tts = new sarvam.TTS({ speaker: 'anushka', model: 'bulbul:v2', targetLanguageCode: 'en-IN', }); ``` -------------------------------- ### Initialize Sarvam AI STT for Transcription Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Initializes the Speech-to-Text (STT) service using Sarvam AI's Saaras models for transcription. Supports specifying the model and language code. This example uses the default streaming WebSocket path. ```typescript import * as sarvam from '@livekit/agents-plugin-sarvam'; const stt = new sarvam.STT({ model: 'saaras:v3', languageCode: 'en-IN', mode: 'transcribe', }); ``` -------------------------------- ### Initialize and Stream Baseten STT Source: https://github.com/livekit/agents-js/blob/main/plugins/baseten/README.md Shows how to configure the STT service and iterate over a stream of speech events. ```typescript import { STT } from 'livekit-plugin-baseten'; const stt = new STT({ apiKey: process.env.BASETEN_API_KEY, modelId: process.env.BASETEN_STT_MODEL_ID }); const stream = stt.stream(); for await (const event of stream) { // Handle speech events } ``` -------------------------------- ### Initialize Baseten LLM Service Source: https://github.com/livekit/agents-js/blob/main/plugins/baseten/README.md Demonstrates how to instantiate the LLM class from the Baseten plugin using an API key and model identifier. ```typescript import { LLM } from 'livekit-plugin-baseten'; const llm = new LLM({ model: 'openai/gpt-4o-mini', apiKey: process.env.BASETEN_API_KEY }); ``` -------------------------------- ### AnamAPI Class Definition Source: https://github.com/livekit/agents-js/blob/main/plugins/anam/etc/agents-plugin-anam.api.md Defines the AnamAPI class for interacting with Anam services. It includes methods for creating session tokens and starting engine sessions. ```typescript import type { Room } from '@livekit/rtc-node'; import { voice } from '@livekit/agents'; // @public (undocumented) export class AnamAPI { constructor(apiKey: string, apiUrl?: string, conn?: APIConnectOptions); // (undocumented) createSessionToken(params: { personaConfig: PersonaConfig; livekitUrl?: string; livekitToken?: string; sessionOptions?: SessionOptions; }): Promise<{ sessionToken: string; }>; // (undocumented) startEngineSession(params: { sessionToken: string; }): Promise<{ sessionId: string; }>; } ``` -------------------------------- ### Realtime Model and TTS Initialization Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Instantiate the realtime model and Text-to-Speech (TTS) client for Gemini. Note that TTS is currently in Beta. ```typescript import * as google from '@livekit/agents-plugin-google'; const realtimeModel = new google.realtime.RealtimeModel({ model: 'gemini-2.5-flash-native-audio-preview-12-2025', }) const geminiTTS = new google.beta.TTS(), ``` -------------------------------- ### Initialize Perplexity LLM Client Source: https://github.com/livekit/agents-js/blob/main/plugins/perplexity/README.md Initialize the Perplexity LLM client. The API key is automatically picked up from the PERPLEXITY_API_KEY environment variable if not provided. ```typescript import { LLM } from '@livekit/agents-plugin-perplexity'; const llm = new LLM({ model: 'sonar-pro', // apiKey is picked up from PERPLEXITY_API_KEY if omitted }); ``` -------------------------------- ### Common Commands for LiveKit Agents.js Source: https://github.com/livekit/agents-js/blob/main/CLAUDE.md A collection of pnpm commands for building, testing, linting, and formatting the LiveKit Agents.js monorepo. Use these for managing the project's development lifecycle. ```bash pnpm build # Build all packages (turbo) pnpm build:agents # Build only @livekit/agents and its deps pnpm build:plugins # Build only plugins and their deps pnpm clean:build # Clean dist/ dirs then rebuild pnpm test # Run all tests (vitest) pnpm test -- --testPathPattern=agents/src/llm # Run tests by path pnpm test -- --testNamePattern="chat context" # Run tests by name pnpm test:watch # Watch mode pnpm lint # ESLint all packages pnpm lint:fix # ESLint with auto-fix pnpm format:check # Prettier check pnpm format:write # Prettier format pnpm api:check # API Extractor validation pnpm api:update # Update API declarations ``` -------------------------------- ### Configure Vertex AI Authentication Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Set up authentication for Vertex AI by logging in with gcloud, setting the project ID, and enabling Vertex AI usage via an environment variable. ```bash gcloud auth application-default login export GOOGLE_CLOUD_PROJECT=your-project-id export GOOGLE_GENAI_USE_VERTEXAI=true ``` -------------------------------- ### Initialize LLM with Mistral AI Source: https://github.com/livekit/agents-js/blob/main/plugins/mistralai/README.md Initialize the LLM component using a Mistral AI model. The API key defaults to process.env.MISTRAL_API_KEY. ```typescript import * as mistral from '@livekit/agents-plugin-mistralai'; const llm = new mistral.LLM({ model: 'mistral-small-latest', // apiKey defaults to process.env.MISTRAL_API_KEY }); ``` -------------------------------- ### Initialize and Synthesize Baseten TTS Source: https://github.com/livekit/agents-js/blob/main/plugins/baseten/README.md Configures the TTS service and demonstrates how to synthesize text into an audio stream. ```typescript import { TTS } from 'livekit-plugin-baseten'; const tts = new TTS({ apiKey: process.env.BASETEN_API_KEY, modelEndpoint: 'your-model-endpoint-url' }); const stream = tts.synthesize('Hello world'); for await (const frame of stream) { // Process audio frames } ``` -------------------------------- ### Debugging Individual Plugins Source: https://github.com/livekit/agents-js/blob/main/CLAUDE.md Command to build and run a test file for debugging a specific plugin. This method avoids the need for the `defineAgent` wrapper. ```bash pnpm build && node ./examples/src/test_my_plugin.ts ``` -------------------------------- ### AvatarSession Constructor Source: https://github.com/livekit/agents-js/blob/main/plugins/liveavatar/README.md Initializes a new AvatarSession with various configuration options. ```APIDOC ## AvatarSession Constructor Options - **avatarId** (string) - Optional - The LiveAvatar avatar id. Falls back to `LIVEAVATAR_AVATAR_ID`. - **apiUrl** (string) - Optional - Override the LiveAvatar API base URL. - **apiKey** (string) - Optional - Your LiveAvatar API key. Falls back to `LIVEAVATAR_API_KEY`. - **isSandbox** (boolean) - Optional - Use the LiveAvatar sandbox (1 minute connection limit). Defaults to `false`. - **videoQuality** ('very_high' | 'high' | 'medium' | 'low') - Optional - Avatar video quality requested from the service. When omitted, the LiveAvatar service decides. - **avatarParticipantIdentity** (string) - Optional - Identity for the avatar participant. Defaults to `'liveavatar-avatar-agent'`. - **avatarParticipantName** (string) - Optional - Display name for the avatar participant. Defaults to `'liveavatar-avatar-agent'`. - **connOptions** (APIConnectOptions) - Optional - API retry/timeout options. ``` -------------------------------- ### Run Basic Agent with Debug Logging Source: https://github.com/livekit/agents-js/blob/main/README.md Execute the basic agent script with debug logging enabled. This is useful for testing changes and plugins. ```bash node ./examples/src/basic_agent.ts dev --log-level=debug ``` -------------------------------- ### License Header for New Files Source: https://github.com/livekit/agents-js/blob/main/CLAUDE.md All new files must include this SPDX license header. ```typescript // SPDX-FileCopyrightText: 2026 LiveKit, Inc. // // SPDX-License-Identifier: Apache-2.0 ``` -------------------------------- ### STTOptions Interface Source: https://github.com/livekit/agents-js/blob/main/plugins/soniox/etc/agents-plugin-soniox.api.md Defines the configuration options available for the STT service. ```APIDOC ## Interface STTOptions ### Description Configuration options for initializing the STT service. ### Properties - `apiKey` (string) - Optional API key for authentication. - `baseUrl` (string) - The base URL for the STT service. - `clientReferenceId` (string) - Optional client reference ID for tracking. - `context` (ContextObject | string) - Optional context information to improve recognition accuracy. - `enableLanguageIdentification` (boolean) - Enables automatic language detection. - `enableSpeakerDiarization` (boolean) - Enables speaker diarization to distinguish between speakers. - `languageHints` (string[]) - An array of language codes to hint at possible languages. - `languageHintsStrict` (boolean) - If true, only languages specified in `languageHints` will be considered. - `maxEndpointDelayMs` (number) - Maximum delay in milliseconds before an endpoint is considered finished. - `model` (string) - The STT model to use. - `numChannels` (number) - The number of audio channels. - `sampleRate` (number) - The audio sample rate. - `translation` (TranslationConfig) - Configuration for translation services. ``` -------------------------------- ### Set Google AI Studio API Key via Environment Variable Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Export your Google AI Studio API key as an environment variable for authentication. ```bash export GOOGLE_API_KEY=your-api-key ``` -------------------------------- ### Initialize STT for Realtime Streaming Source: https://github.com/livekit/agents-js/blob/main/plugins/mistralai/README.md Initialize the STT component for realtime streaming. This requires a VAD and uses a specific realtime model. If no VAD is provided, Silero VAD is loaded automatically. ```typescript // Realtime streaming (requires a VAD) const stt = new mistral.STT({ model: 'voxtral-mini-transcribe-realtime-2602', }); ``` -------------------------------- ### Advanced LLM Configuration Source: https://github.com/livekit/agents-js/blob/main/plugins/google/README.md Configure advanced LLM parameters such as temperature, max output tokens, topP, topK, and tool choice for more fine-tuned model behavior. ```typescript const llm = new LLM({ model: 'gemini-1.5-pro', temperature: 0.7, maxOutputTokens: 2048, topP: 0.8, topK: 40, toolChoice: 'auto', }); ``` -------------------------------- ### Initialize Perplexity Agent API LLM Client Source: https://github.com/livekit/agents-js/blob/main/plugins/perplexity/README.md Initialize the Perplexity LLM client for the Agent API. This client uses a specific base URL and disables WebSocket transport. ```typescript import { responses } from '@livekit/agents-plugin-perplexity'; const llm = new responses.LLM({ model: 'sonar-pro', // apiKey is picked up from PERPLEXITY_API_KEY if omitted }); ``` -------------------------------- ### SessionOptions Type Source: https://github.com/livekit/agents-js/blob/main/plugins/anam/etc/agents-plugin-anam.api.md Options for configuring a session. ```APIDOC ## Type: SessionOptions ### Description Defines options that can be applied to a session, such as video dimensions. ### Properties - **videoWidth** (number) - Optional - The desired width of the video stream. - **videoHeight** (number) - Optional - The desired height of the video stream. ``` -------------------------------- ### AvatarSession Constructor Source: https://github.com/livekit/agents-js/blob/main/plugins/bey/README.md Initializes a new AvatarSession for managing Beyond Presence avatars. ```APIDOC ## AvatarSession Creates a new Beyond Presence avatar session. ### Constructor Options - **avatarId** (string) - Optional - The avatar ID to use. Defaults to stock avatar. - **apiUrl** (string) - Optional - The Bey API URL. Defaults to `https://api.bey.dev`. - **apiKey** (string) - Optional - Your Bey API key. Can also be set via `BEY_API_API_KEY` environment variable. - **avatarParticipantIdentity** (string) - Optional - The identity for the avatar participant. Defaults to `'bey-avatar-agent'`. - **avatarParticipantName** (string) - Optional - The name for the avatar participant. Defaults to `'bey-avatar-agent'`. - **connOptions** (APIConnectOptions) - Optional - Connection options for retry logic. ``` -------------------------------- ### Initialize TTS with Mistral AI Source: https://github.com/livekit/agents-js/blob/main/plugins/mistralai/README.md Initialize the TTS component using a Mistral AI model and a specific voice preset. ```typescript const tts = new mistral.TTS({ model: 'voxtral-mini-tts-latest', voice: 'en_paul_neutral', }); ``` -------------------------------- ### LLMOptions Interface Source: https://github.com/livekit/agents-js/blob/main/plugins/perplexity/etc/agents-plugin-perplexity.api.md Configuration options for the Perplexity LLM client. ```APIDOC ## LLMOptions Interface ### Description Configuration options for the Perplexity LLM client. ### Fields - **apiKey** (string) - Optional - The API key for Perplexity. - **baseURL** (string) - Optional - The base URL for the Perplexity API. - **client** (OpenAI) - Optional - An existing OpenAI client instance. - **model** (string | PerplexityChatModels) - Required - The Perplexity model to use (e.g., 'sonar-pro'). - **parallelToolCalls** (boolean) - Optional - Whether to enable parallel tool calls. - **temperature** (number) - Optional - The sampling temperature. - **toolChoice** (llm.ToolChoice) - Optional - Configuration for tool choice. - **topP** (number) - Optional - The nucleus sampling probability. ``` -------------------------------- ### Migrate Import Path Source: https://github.com/livekit/agents-js/blob/main/plugins/mistral/README.md Update your import statements to use the new package name when migrating from the deprecated plugin. ```diff - import * as mistral from '@livekit/agents-plugin-mistral'; + import * as mistral from '@livekit/agents-plugin-mistralai'; ``` -------------------------------- ### Set Bey API Key Environment Variable Source: https://github.com/livekit/agents-js/blob/main/plugins/bey/README.md Sets the BEY_API_KEY environment variable with your developer API key obtained from the Bey creator dashboard. This key is required for authenticating with the Bey service. ```bash export BEY_API_KEY= ``` -------------------------------- ### Initialize Sarvam AI STT for Translation Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Initializes the Speech-to-Text (STT) service using Sarvam AI's Saaras models for translation from an Indic language to English. Requires specifying a prompt for context. Authentication can be handled via the SARVAM_API_KEY environment variable or by passing the apiKey directly. ```typescript import * as sarvam from '@livekit/agents-plugin-sarvam'; const stt = new sarvam.STT({ model: 'saaras:v2.5', prompt: 'Technical interview discussion', }); ``` -------------------------------- ### Configure Trugen API Key Source: https://github.com/livekit/agents-js/blob/main/plugins/trugen/README.md Sets the TRUGEN_API_KEY environment variable with your developer API key obtained from the Trugen dashboard. This key is required for authenticating with the Trugen service. ```bash export TRUGEN_API_KEY= ``` -------------------------------- ### Initialize Sarvam AI STT (Non-Streaming REST) Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Initializes the Speech-to-Text (STT) service using Sarvam AI's Saaras models in a non-streaming mode, preferring REST over WebSocket. This configuration will result in LiveKit using Voice Activity Detection (VAD) and non-streaming recognize() calls within an AgentSession. ```typescript import * as sarvam from '@livekit/agents-plugin-sarvam'; const stt = new sarvam.STT({ model: 'saaras:v3', streaming: false, }); ``` -------------------------------- ### Initialize STT for Batch Transcription Source: https://github.com/livekit/agents-js/blob/main/plugins/mistralai/README.md Initialize the STT component for batch transcription using a specified Mistral AI model. ```typescript // Batch transcription const stt = new mistral.STT({ model: 'voxtral-mini-latest' }); ``` -------------------------------- ### STTOptions Interface Source: https://github.com/livekit/agents-js/blob/main/plugins/soniox/etc/agents-plugin-soniox.api.md Defines the configuration options for STT services, including API keys, base URLs, language identification, speaker diarization, and model settings. ```typescript export interface STTOptions { // (undocumented) apiKey?: string; // (undocumented) baseUrl: string; // (undocumented) clientReferenceId?: string; // (undocumented) context?: ContextObject | string; // (undocumented) enableLanguageIdentification: boolean; // (undocumented) enableSpeakerDiarization: boolean; // (undocumented) languageHints?: string[]; // (undocumented) languageHintsStrict: boolean; maxEndpointDelayMs: number; // (undocumented) model: string; // (undocumented) numChannels: number; // (undocumented) sampleRate: number; // (undocumented) translation?: TranslationConfig; } ``` -------------------------------- ### Set LiveAvatar API Key Source: https://github.com/livekit/agents-js/blob/main/plugins/liveavatar/README.md Set the LIVEAVATAR_API_KEY environment variable with your developer API key from the LiveAvatar dashboard. ```bash export LIVEAVATAR_API_KEY= ``` -------------------------------- ### Initialize Sarvam AI TTS (Non-Streaming REST) Source: https://github.com/livekit/agents-js/blob/main/plugins/sarvam/README.md Initializes the Text-to-Speech (TTS) service using Sarvam AI's Bulbul models in a non-streaming mode, preferring REST over WebSocket. This configuration will result in LiveKit using sentence chunking and non-streaming synthesize() calls within an AgentSession. ```typescript import * as sarvam from '@livekit/agents-plugin-sarvam'; const tts = new sarvam.TTS({ model: 'bulbul:v2', streaming: false, }); ``` -------------------------------- ### LLM Class Source: https://github.com/livekit/agents-js/blob/main/plugins/perplexity/etc/agents-plugin-perplexity.api.md Represents a Language Model client for Perplexity. It extends the base LLM class from `@livekit/agents-plugin-openai` and provides Perplexity-specific configurations. ```APIDOC ## LLM Class ### Description Represents a Language Model client for Perplexity. It extends the base LLM class from `@livekit/agents-plugin-openai` and provides Perplexity-specific configurations. ### Methods - **constructor(opts?: Partial)**: Initializes a new instance of the LLM class. - **label()**: Returns the label for this LLM instance. - **provider**: Returns the provider name for this LLM instance. ### Properties - **provider**: string - The name of the LLM provider. ``` -------------------------------- ### ContextObject Interface Source: https://github.com/livekit/agents-js/blob/main/plugins/soniox/etc/agents-plugin-soniox.api.md Provides structured context for speech recognition, including general terms, specific terms, and translation configurations. ```APIDOC ## Interface ContextObject ### Description Represents contextual information to enhance speech recognition accuracy. ### Properties - `general` (ContextGeneralItem[]) - An array of general key-value pairs for context. - `terms` (string[]) - An array of specific terms to recognize. - `text` (string) - A block of text for context. - `translationTerms` (ContextTranslationTerm[]) - Configuration for translation terms. ``` -------------------------------- ### APIConnectOptions Type Source: https://github.com/livekit/agents-js/blob/main/plugins/anam/etc/agents-plugin-anam.api.md Configuration options for API connections. ```APIDOC ## Type: APIConnectOptions ### Description Defines options for configuring API connections, such as retry mechanisms and timeouts. ### Properties - **maxRetry** (number) - Optional - The maximum number of retries for a connection attempt. - **retryInterval** (number) - Optional - The interval in milliseconds between retry attempts. - **timeout** (number) - Optional - The timeout in milliseconds for connection attempts. ``` -------------------------------- ### Initialize Avatar Session Source: https://github.com/livekit/agents-js/blob/main/plugins/runway/README.md Initialize an AvatarSession with a preset ID. The API key defaults to the RUNWAYML_API_SECRET environment variable. ```typescript import { AvatarSession } from '@livekit/agents-plugin-runway'; const avatarSession = new AvatarSession({ presetId: 'your-avatar-preset-id', // apiKey defaults to RUNWAYML_API_SECRET env var }); await avatarSession.start(agentSession, room); ```