steep-balloon-41261
11/08/2025, 1:32 AMtall-airline-16756
11/08/2025, 1:32 AMtall-airline-16756
11/08/2025, 1:33 AMimport asyncio
import logging
from dotenv import load_dotenv
from livekit.agents import (Agent, AgentSession, AudioConfig, BackgroundAudioPlayer, BuiltinAudioClip, JobContext, WorkerOptions, cli)
from livekit.plugins import openai
logger = logging.getLogger("typing-hello-agent")
load_dotenv()
class TypingHelloAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a helpful assistant")
async def entrypoint(ctx: JobContext):
await ctx.connect()
logger.info('Connected to room')
session = AgentSession(llm=openai.realtime.RealtimeModel())
await session.start(TypingHelloAgent(), room=ctx.room)
background_audio = BackgroundAudioPlayer(
thinking_sound=[
AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING, volume=0.8),
AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING2, volume=0.7),
],
)
await background_audio.start(room=ctx.room, agent_session=session)
await session.say("Hello. How can I help you today?", allow_interruptions=False)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Make sure you’ve set up the necessary environment variables for the LiveKit server connection and API keys. If you have any questions or need a hand with anything else, please don’t hesitate to ask—I’m here to help!
Sources: Node.js Agents Architecture | livekit/livekit_composite | DeepWiki | README.md | examples/voice_agents/langgraph_agent.py | Agent speech and audio | LiveKit docsdazzling-truck-32153
11/08/2025, 1:35 AMtall-airline-16756
11/08/2025, 1:37 AMimport {
type JobContext,
WorkerOptions,
cli,
defineAgent,
voice,
} from '@livekit/agents';
import * as openai from '@livekit/agents-plugin-openai';
import * as elevenlabs from '@livekit/agents-plugin-elevenlabs';
import * as deepgram from '@livekit/agents-plugin-deepgram';
export default defineAgent({
entry: async (ctx: JobContext) => {
// Connect to the room
await ctx.connect();
// Create the agent
const agent = new voice.Agent({
instructions: 'You are a helpful assistant.',
stt: new deepgram.STT(),
llm: new openai.LLM({ model: 'gpt-4o-mini' }),
tts: new elevenlabs.TTS(),
});
const session = new voice.AgentSession({
stt: new deepgram.STT(),
llm: new openai.LLM({ model: 'gpt-4o-mini' }),
tts: new elevenlabs.TTS(),
});
await session.start({
agent,
room: ctx.room,
});
// Have the agent greet the user
await session.say('Hello, how can I assist you today?');
},
});
cli.runApp(new WorkerOptions({ agent: 'path-to-your-agent-file' }));
This example brings together LLM, TTS, and STT using plugins like OpenAI, ElevenLabs, and Deepgram to help you get started smoothly. If you have any questions or want to explore additional features, please feel free to ask—I'm here to help!
Sources: examples/src/basic_tool_call_agent.ts | Ultravox plugin guide | LiveKit Docs | agent.pydazzling-truck-32153
11/08/2025, 1:40 AMtall-airline-16756
11/08/2025, 1:40 AM