Usage
Add your LiveKit API keys to a
.env.localfile in your project root.LIVEKIT_API_KEY=your-api-keyLIVEKIT_API_SECRET=your-api-secretLIVEKIT_URL=your-livekit-urlCreate a new TokenSource that points your new
/api/tokenendpoint.'use client';import { useSession } from '@livekit/components-react';import { AgentSessionProvider } from '@/components/agents-ui/agent-session-provider';import MyAgent from '@/components/my-agent';const TOKEN_SOURCE = TokenSource.endpoint('/api/token');export function Demo() {const session = useSession(TOKEN_SOURCE);return (<AgentSessionProvider session={session}><MyAgent /></AgentSessionProvider>);}
Features
- Generates a LiveKit session token using a NextJS API route
- Keeps your API keys private
This route requires authentication in production
This route is insecure by default to enable local development.
Installation
pnpm dlx shadcn@latest add @agents-ui/nextjs-api-token-route