does it work with typescript and gemini for multim...
# ask-ai
r
does it work with typescript and gemini for multimodal models import { JobContext, WorkerOptions, cli, defineAgent, multimodal } from '@livekit/agents'; import * as openai from '@livekit/agents-plugin-openai'; export default defineAgent({ entry: async (ctx: JobContext) => { await ctx.connect(); const agent = new multimodal.MultimodalAgent({ model: new openai.realtime.RealtimeModel({ instructions: "You are a helpful assistant.", voice: 'shimmer', modalities: ['text', 'audio'], }), }); await agent.start(ctx.room); }, }); cli.runApp(new WorkerOptions({ agent: import.meta.url, workerType: JobType.JT_ROOM }));
t
Thanks for reaching out, Hrithik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! I wanted to share some helpful info about LiveKit and how it supports both TypeScript and Gemini for multimodal models. The code snippet you mentioned using
@livekit/agents
and
@livekit/agents-plugin-openai
is actually tailored for OpenAI’s Realtime API, so it won’t work directly with Gemini. To get things working smoothly with Gemini, here’s what you’ll want to do: • Use the
@livekit/agents-plugin-google
package instead. • Swap out the model for
google.beta.realtime.RealtimeModel
. Here’s a little example to guide you on updating your code for Gemini:
Copy code
import { defineAgent, JobContext } from '@livekit/agents';
import * as google from '@livekit/agents-plugin-google';

export default defineAgent({
  entry: async (ctx: JobContext) => {
    await ctx.connect();
    const participant = await ctx.waitForParticipant();

    const model = new google.beta.realtime.RealtimeModel({
      instructions: 'You are a helpful assistant.',
    });

    const agent = new multimodal.MultimodalAgent({ model });
    await agent.start(ctx.room, participant);
  },
});
If you have any questions or need a hand with this, please don’t hesitate to reach out. I’m here to help! Sources: plugins/openai/src/models.ts | LiveKit integration guides | LiveKit Docs | Large language model (LLM) integrations | LiveKit Docs | packages/sip--make-a-call/src/agent.ts | package.json