when running a livekit service in python have egre...
# ask-ai
f
when running a livekit service in python have egress connect before the session start and some logic of sending transcript at the end of the conversation to the server. can i set up all this logic for a human video conference? even without any agent deployment? and run this service on the cloud?
t
Thanks for reaching out, Gad. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you understand how LiveKit can support your needs for a human video conference, with a few important points to keep in mind: • Egress Connection: Just a heads-up, Egress can only connect once the session has started. So, recording will begin as soon as the session is active. • Transcript Generation: Currently, Egress doesn’t generate or send transcripts on its own. To get transcripts, you’ll want to set up an AI agent that uses speech-to-text (STT) technology. • Cloud Operation: If you’re using LiveKit Cloud, the Egress part is fully managed for you—no need to worry about deploying agents there. However, you’ll still need to deploy an AI agent to handle generating and delivering the transcripts. So, a great way to reach your goal is by using LiveKit Cloud for the managed Egress recording, and pairing it with an AI agent to create and deliver transcripts once the session wraps up. Please feel free to reach out if you’d like more details or help setting this up—I’m here for you! Sources: Session recording and transcripts | LiveKit Docs | Recording and export | LiveKit docs | complex-agents/teleprompter/cartesia-ink.py | test/agents/guest.py
f
yeah i want to have hidden transcriber agent to transcribe the participants for the video conference but without any voice agent joining the room. how would the livekit code look in this case?
t
I'd love to help you set up a hidden transcriber agent for your video conference! You can create an agent that listens to participants' audio tracks, transcribes their speech using a Speech-to-Text (STT) plugin, and stays completely silent by not publishing any audio or video. Here’s a simple outline to guide you: 1. Install Dependencies: Start by using LiveKit Agents along with an STT plugin like OpenAI Whisper or Deepgram. 2. Create the Agent: Build an agent that subscribes to audio-only streams and transcribes them. Just make sure it doesn’t publish any audio or video to stay hidden. 3. Run the Agent: Launch the agent in the background with audio output turned off so it remains invisible. 4. Optional: You can use LiveKit's text streams to send the transcriptions back to the room or save them externally. If you’d like, I’d be happy to provide detailed code examples or walk you through any part of this setup. Just let me know how I can assist you further! Sources: docs/index.yaml | examples/other/transcription/translator.py | Text and transcriptions | LiveKit docs | Rooms, participants, and tracks | LiveKit docs
f
how do i connect an agent to the room with no output? currently when i run this line the agent connects visibly to the room: await self.ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
t
I'd love to help you connect an agent to the room without it being visible or showing any output. You can easily do this by setting the
hidden
parameter in the
WorkerPermissions
. Here’s a simple example in Python to guide you:
Copy code
from livekit.agents import WorkerOptions, WorkerPermissions

opts = WorkerOptions(
    permissions=WorkerPermissions(
        can_publish=True,
        can_subscribe=True,
        can_publish_data=True,
        hidden=True,  # This makes the agent invisible to others
    ),
)
This way, your agent will be able to subscribe to audio tracks and handle data quietly, without being seen by other participants. If you have any questions or want to explore this further, just let me know—I’m here to help! Sources: Worker options | LiveKit Docs | Text and transcriptions | LiveKit docs | Rooms, participants, and tracks | LiveKit docs
f
okay this works, now i have two agents, one that is hidden by default that joins the human led conversations. and one that is not hidden and joins regular conversations. can i host those two agent in livekit cloud at the same time and choose which one to dispatch through the token dispatch room config?
t
Absolutely! LiveKit Cloud is designed to support multiple agents, whether they're hidden or visible, all at the same time. You can easily manage which agent gets dispatched when a participant joins a room by using the token's
RoomConfiguration
. Here’s a simple example to guide you:
Copy code
at.roomConfig = new RoomConfiguration({
  agents: [
    new RoomAgentDispatch({ agentName: "hiddenAgent", metadata: "..." }),
    new RoomAgentDispatch({ agentName: "visibleAgent", metadata: "..." })
  ]
});
This way, you have clear and precise control over agent assignments for each session. If you have any questions or need a hand with setting this up, please don’t hesitate to reach out—I’m here to help! Sources: Authentication | LiveKit Docs | packages/livekit-server-sdk/src/AgentDispatchClient.ts | SIP Integration & Telephony | livekit/livekit_composite | DeepWiki | examples/agent_dispatch.py | Agent dispatch | LiveKit Docs
f
how do i deploy a second agent through the cli with a specific name?
t
Hi there! I wanted to share that the LiveKit CLI doesn’t directly let you set a specific name for an agent during deployment, but don’t worry—we have some great ways to achieve this: 1. Using
agent_name
in Code:
You can set the
agent_name
in the agent’s
WorkerOptions
to clearly identify your agent when dispatching. Here’s a quick example:
Copy code
opts = WorkerOptions(
    agent_name="my-custom-agent",
)
1. Separate Project Directories: Another approach is to deploy each agent from its own directory, each with its own unique configuration. 2. Configuration Files: You can also use different config files like
livekit-agent1.toml
and
livekit-agent2.toml
, then deploy using the
--config
flag like this:
Copy code
lk agent deploy --config livekit-agent1.toml
If you’d like, I’m here to help you set up these configurations or organize multiple agents so everything runs smoothly. Just let me know! Sources: Agent deployment CLI reference | LiveKit docs | livekit/livekit_cloud_agent.pb.go | cmd/lk/agent.go | Deploying to production | LiveKit Docs | Agent dispatch | LiveKit Docs
f
explain how to deploy two diffrent agent from within the same directory each having a diffrent entry point.
t
To help you deploy two different agents from the same directory, each with its own entry point, here’s a simple step-by-step guide you can follow: 1. Create Separate Entry Points: Start by defining distinct Python files for each agent. For example:
Copy code
# guest.py
from livekit.agents import JobContext, WorkerOptions, cli

async def guest_entrypoint(ctx: JobContext):
    await ctx.connect()
    # Guest-specific logic

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=guest_entrypoint))
Copy code
# host.py
from livekit.agents import JobContext, WorkerOptions, cli

async def host_entrypoint(ctx: JobContext):
    await ctx.connect()
    # Host-specific logic

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=host_entrypoint))
1. Deploy Each Agent: Next, you can use the LiveKit CLI to deploy each agent, making sure to give each a unique ID or configuration:
Copy code
# Deploy guest agent
lk agent deploy --id guest-agent-id /path/to/your/directory

# Deploy host agent
lk agent deploy --id host-agent-id /path/to/your/directory
1. Optional: If you’d prefer, you can also manage multiple agents dynamically by using environment variables or a single file with conditional entry points. If you have any questions or need a hand with any part of this setup, please don’t hesitate to reach out—I’m here to help! Sources: test/agents.go | Builds and Dockerfiles | LiveKit Docs | Agent deployment CLI reference | LiveKit docs
f
can i control the hidden state of an agent from within the entrycode logic?
t
I understand that figuring out the hidden state of an agent can be a bit tricky! The
hidden
property in the
WorkerPermissions
is what sets this state during the agent's initialization. Just a heads-up, this can't be changed dynamically while the agent is running through the entry code logic. If you want to change the hidden state, you'll need to redeploy the agent with the new settings. If you'd like, I'm here to help you step-by-step with setting up or redeploying agents with the visibility configuration that works best for you. Just let me know! Sources: livekit-protocol/livekit/protocol/models.pyi | Node.js Agents Architecture | livekit/livekit_composite | DeepWiki | agent-console/app/_components/participant-action-panel.tsx | Rooms, participants, and tracks | LiveKit docs
f
can i control the visibility of the agent through the token room config?
t
I understand you're looking into controlling an agent's visibility through the token's
VideoGrant
configuration. The
hidden
field in
VideoGrant
is meant to hide participants from others in the room, which might be just what you need. However, it's not clearly documented if this applies to agents dispatched via the token's
RoomConfiguration
. A great way to find out is by testing it yourself—try setting
hidden: true
in the
VideoGrant
of the token used to dispatch the agent. If you'd like, I'm here to help you step-by-step with configuring or testing this setup. Just let me know! Sources: Authentication | LiveKit Docs | lib/src/token_source/token_source.dart | Sources/LiveKit/Agent/Session.swift