i want to self deploy the agent is it possile?
# ask-ai
s
i want to self deploy the agent is it possile?
t
Thanks for reaching out, ABHIRAM. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, you can self-deploy LiveKit agents! The LiveKit Agents framework is open source, which means you have the flexibility to deploy it on your own infrastructure. This gives you full control over your environment and scalability, which is fantastic. You can use platforms like Kubernetes, AWS ECS, Fly.io, and other container orchestration systems. Even with self-hosted agents, you still get to benefit from LiveKit’s global edge network for real-time media transport, and billing is based on your actual resource usage. To make things easier, there are deployment examples available, including Dockerfiles and configuration templates for various platforms. If you’d like to dive into the details, I recommend checking out the Deploying to custom environments documentation. It’s a great resource to guide you through the process. Sources: README.md | Voice AI quickstart | LiveKit Docs | Deploying to custom environments | LiveKit Docs
s
how many agents can it hanle
t
Thank you for your question! The number of agents you can manage in a self-deployed environment really depends on your hardware resources and how your infrastructure is set up. Since agents can be quite resource-intensive, a single machine usually supports around "tens" of active voice calls. If you're working with video agents or more complex tasks, you might need to allocate additional resources to keep things running smoothly. LiveKit is designed with scalability in mind, capable of handling up to 100,000 simultaneous participants per session and even millions through its distributed mesh architecture. When you’re self-hosting, there aren’t any artificial limits—you can scale according to your hardware and configuration, which is great for flexibility. To get the most out of your setup, I’d recommend looking into container orchestration tools like Kubernetes, using worker pool models, and running load tests to find the best capacity for your needs. If you'd like, I’m here to help guide you through load testing or figuring out the right infrastructure size for your workload. Just let me know! Sources: Deploy and scale agents on LiveKit Cloud | Deploy and scale agents on LiveKit Cloud | LiveKit Pricing | README.md | delay-handling/raw_data.txt
s
can i change the agents prompt everytime i need?
t
Absolutely, you can change the agent's prompt dynamically and as often as you need. LiveKit offers handy methods like
update_instructions()
that let you update the agent's core instructions in real-time. This means you can easily tailor the agent's behavior based on things like the participant's identity or the context you're working with. On top of that, you can also swap out the entire chat context on the fly using
update_chat_ctx()
. This is great for more advanced scenarios, like switching personas or smoothly moving between different phases of a conversation. If you'd like, I’m here to help with more details or examples on how to set these up—just let me know! Sources: complex-agents/ivr-agent/README.md | Workflows | LiveKit Docs | Agent Session & Activity Management | livekit/livekit_composite | DeepWiki | livekit-agents/livekit/agents/voice/agent_activity.py
s
so for every user based on the id i need to change the prompt
t
I'm happy to guide you through how you can dynamically change the agent's prompt based on the user ID during runtime. Here’s a simple way to approach it: 1. Access User Identity: You can use
self.session.participant
to get user-specific details like their ID or other attributes. This helps in tailoring the experience just for them. 2. Update Instructions: With the
update_instructions()
method, you can easily modify the agent's core instructions on the fly. For instance, checking the user ID and adjusting the prompt to fit their needs. 3. Personalize Chat Context: Using
update_chat_ctx()
, you can add user-specific details into the chat context—like their name or preferences—to make the interaction feel more personal. 4. Store User Data: Don’t forget to save important user information in
session.userdata
. This helps keep the conversation consistent and allows the agent to behave in a more informed way. If you’d like, I’d be more than happy to provide detailed code examples or walk you through the implementation step-by-step. Just let me know! Sources: pipeline-tts/tts_comparison/README.md | agent/main.py
s
can yo uprovide me th ecode?
t
I'd love to share an example with you on how to dynamically adjust the agent's prompt based on the user ID. Take a look:
Copy code
from dataclasses import dataclass

@dataclass
class UserData:
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    customer_id: Optional[str] = None

    def is_identified(self) -> bool:
        return self.first_name is not None and self.last_name is not None

    def summarize(self) -> str:
        if self.is_identified():
            return f"Customer: {self.first_name} {self.last_name} (ID: {self.customer_id})"
        return "Customer not yet identified."

class CustomAgent:
    async def on_enter(self):
        userdata: UserData = self.session.userdata
        custom_instructions = self.instructions

        if userdata.is_identified():
            custom_instructions += f"\n\nYou are speaking with {userdata.first_name} {userdata.last_name}."

        chat_ctx = self.chat_ctx.copy()
        chat_ctx.add_message(
            role="system",
            content=f"You are the {self.__class__.__name__}. {userdata.summarize()}"
        )

        await self.update_chat_ctx(chat_ctx)
        self.session.generate_reply()
Here's what's happening in this example: • We store user-specific data like first name, last name, and customer ID in
session.userdata
. • The agent's instructions get updated on the fly, depending on whether we can identify the user. • The chat context becomes more personalized by adding these details through
update_chat_ctx()
. If anything feels unclear or if you'd like me to walk you through more examples, just let me know—I'm here to help!
s
i have used docker to run livekit server
t
Let's walk through how to configure your LiveKit server with Docker together—it’s simpler than it sounds! Here’s what you’ll want to do: 1. Create a Configuration File: Start by defining a YAML configuration file that includes your API key, API secret, WebSocket URL, and Redis connection details. Here’s a quick example to guide you:
Copy code
api_key: your-api-key
api_secret: your-api-secret
ws_url: ws://host.docker.internal:7880
redis:
  address: host.docker.internal:6379
1. Run the Docker Container: You’ll pass your configuration using the
LIVEKIT_CONFIG
environment variable. Here’s how you can do it:
Copy code
docker run --rm \
  -e LIVEKIT_CONFIG="$(cat config.yaml)" \
  --network host \
  livekit/livekit-server
1. Use Docker Compose: If your setup is a bit more complex, Docker Compose is a great way to manage services like Redis and TLS smoothly. LiveKit even offers a pre-configured setup to help you get started. 2. Open Required Ports: Don’t forget to make sure ports like 7880 (WebSocket), 7881 (gRPC), and the UDP range (for example, 50000–60000) are open and accessible. If you’d like to dive deeper, the sample config is a wonderful resource. And of course, I’m here if you have any questions or need a hand with anything else! Sources: README.md | README.md | Deploy to a VM | LiveKit Docs | Self-hosted SIP server | LiveKit Docs | Deploying LiveKit | LiveKit Docs
s
(base) abhiramvarrey@Admins-MacBook-Pro-4 livekit % brew update && brew install livekit ==> Updating Homebrew... Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae pydantic-core: Core functionality for Pydantic validation and serialization ==> New Casks fastmail: Email client liquibase-community: Library for database change tracking liquibase-secure: Database change management tool ==> Outdated Formulae libunistring node unixodbc mongodb-community@7.0 simdjson You have 5 outdated formulae installed. You can upgrade them with brew upgrade or list them with brew outdated. ==> Fetching downloads for: livekit ==> Downloading https://ghcr.io/v2/homebrew/core/livekit/manifests/1.9.1 ######################################################################### 100.0% ==> Fetching livekit ==> Downloading https://ghcr.io/v2/homebrew/core/livekit/blobs/sha256:fc56be398a ######################################################################### 100.0% ==> Pouring livekit--1.9.1.arm64_sequoia.bottle.tar.gz 🍺 /opt/homebrew/Cellar/livekit/1.9.1: 8 files, 38.9MB ==> Running
brew cleanup livekit
...
Disable this behaviour by setting
HOMEBREW_NO_INSTALL_CLEANUP=1
. Hide these hints with
HOMEBREW_NO_ENV_HINTS=1
(see
man brew
). (base) abhiramvarrey@Admins-MacBook-Pro-4 livekit % livekit-server --dev 2025-10-14T170155.505+0530 INFO livekit server/main.go:212 starting in development mode 2025-10-14T170155.506+0530 INFO livekit server/main.go:215 no keys provided, using placeholder keys {"API Key": "devkey", "API Secret": "secret"} 2025-10-14T170155.506+0530 INFO livekit routing/interfaces.go:180 using single-node routing 2025-10-14T170155.508+0530 INFO livekit service/server.go:264 starting LiveKit server {"portHttp": 7880, "nodeID": "ND_7vKA8ma9KpZE", "nodeIP": "192.168.10.19", "version": "1.9.1", "bindAddresses": ["127.0.0.1", "::1"], "rtc.portTCP": 7881, "rtc.portUDP": {"Start":7882,"End":0}} 2025-10-14T170155.508+0530 DEBUG livekit service/signal.go:119 starting relay signal server {"topic": "ND_7vKA8ma9KpZE"} 2025-10-14T180136.536+0530 INFO livekit hwstats/cpu.go:129 high cpu load {"load": 0.9168336673346693} 2025-10-14T183622.250+0530 INFO livekit hwstats/cpu.go:129 high cpu load {"load": 0.9374369323915237} is my log
t
Thanks for sharing the log! It looks like your LiveKit server is up and running smoothly in development mode. Here are a few important things I noticed from the log: • Your server is currently using placeholder keys (
API Key: devkey
,
API Secret: secret
), which are perfect for development but you'll want to swap them out for secure keys when you move to production. • Single-node routing is enabled, which is common for development setups. • The server is set to run on HTTP port 7880, TCP port 7881, and UDP starting at port 7882. • There are some high CPU load warnings, which might mean your machine is feeling a bit stretched. If you’re thinking about moving to production, here are some friendly tips to keep in mind: 1. Switch out those placeholder API keys for secure ones to keep everything safe. 2. Make sure your hardware has enough resources to handle the load you expect. 3. If you need scalability, consider setting up multi-node routing. 4. Don’t forget to open the necessary ports (7880, 7881, and the UDP range) in your firewall so everything can communicate properly. Please feel free to reach out if you want a hand with any specific settings or if you run into any issues—I’m here to help!
s
i want to use docker instead of cloud i want to use it
t
I'm glad you're exploring the option to self-host the LiveKit server using Docker! It’s a great way to have more control. Here’s a simple step-by-step guide to help you get started: 1. Pull the LiveKit Docker Image: You can download the LiveKit server image by running this command:
docker pull livekit/livekit-server
2. Create a Configuration File: Next, you'll want to create a YAML configuration file (for example,
config.yaml
) where you’ll specify your API key, API secret, WebSocket URL, and Redis connection details. Here’s a sample to guide you:
Copy code
api_key: your-api-key
api_secret: your-api-secret
ws_url: ws://host.docker.internal:7880
redis:
  address: host.docker.internal:6379
3. Run the Docker Container: Now, start the LiveKit server using your configuration file with this command:
Copy code
docker run --rm \
  -e LIVEKIT_CONFIG="$(cat config.yaml)" \
  --network host \
  livekit/livekit-server
4. Open Required Ports: To make sure everything works smoothly, please open these ports for external access: ◦ 7880 (WebSocket) ◦ 7881 (gRPC) ◦ UDP range (like 50000–60000 for WebRTC) 1. Test the Setup: Finally, check that your server is up and running by connecting to the WebSocket URL, for example:
ws://localhost:7880
. If you run into any questions or need a hand with the setup or tweaking the configuration, please don’t hesitate to reach out. I’m here to help!
s
ok i have used the docker i want to create a n agent in python to connect to the agent
t
I'm excited to help you create a Python agent that connects to your LiveKit server! Let's walk through the steps together: 1. Set Up Python Environment: First, you'll want to install the required package. You can do this easily by running:
pip install "livekit-agents[openai,silero,deepgram,cartesia]~=1.0"
2. Define the Agent Entry Point: Next, create a function that connects your agent to the LiveKit server and handles jobs. Here's a simple example to get you started:
Copy code
from livekit import agents
from livekit.agents import JobContext, cli

async def entrypoint(ctx: JobContext):
    await ctx.connect()
    print(f"Agent connected to room: {ctx.room.name}")

if __name__ == "__main__":
    cli.run_app(entrypoint)
3. Configure Worker Options: To tailor your agent's behavior, you can use
WorkerOptions
for settings like memory limits, permissions, and connection retries. Here's how you might set that up:
Copy code
from livekit.agents import WorkerOptions

options = WorkerOptions(
    load_threshold=0.8,
    job_memory_warn_mb=750,
    job_memory_limit_mb=2048,
    permissions=WorkerPermissions(can_publish=True, can_subscribe=True),
)
cli.run_app(entrypoint, options)
4. Run the Agent: Finally, you can start your agent by running this command:
python your_agent.py
If you have any questions or would like me to provide a more detailed example, please don't hesitate to ask. I'm here to help! Sources: agent/main.py | Voice AI quickstart | LiveKit Docs | agent.py | README.md | python-agent-example-app/main.py
s
i want to use my running docker
t
To help you connect your Python agent to the LiveKit server running in Docker, here’s a simple step-by-step guide: 1. Update the WebSocket URL: You’ll want to use the WebSocket URL of your Docker container. If it’s running locally, it might look something like this: `ws://localhost:7880`Just remember to replace
localhost
with the correct IP address if your server is on a different machine. 2. Set Up Environment Variables: It’s a good idea to store the WebSocket URL, API key, and API secret in a
.env
file for easy management:
Copy code
LIVEKIT_API_KEY=your_api_key
LIVEKIT_API_SECRET=your_api_secret
LIVEKIT_URL=ws://localhost:7880
3. Modify the Agent Code: Next, update the
WorkerOptions
in your Python agent to include the WebSocket URL and your credentials:
Copy code
from livekit.agents import WorkerOptions

options = WorkerOptions(
    ws_url="ws://localhost:7880",
    api_key="your_api_key",
    api_secret="your_api_secret",
)
cli.run_app(entrypoint, options)
4. Run the Agent: Finally, start your Python agent and make sure it connects smoothly to your Docker-hosted LiveKit server:
python your_agent.py
If you run into any bumps or have questions about specific settings, feel free to reach out—I’m here to help!
s
will this yaml file work ? # LiveKit server configuration keys: mykey: mysecret port: 7880 rtc: udp_port: 7881 tcp_port: 7882 any extra configs
t
Your YAML file is a great starting point! To make your setup even more robust, here are a few friendly suggestions you might find helpful: 1. Redis Configuration: If you’re thinking about using multiple nodes or want distributed operation, adding Redis settings can really help:
Copy code
redis:
  address: host.docker.internal:6379
2. WebRTC Port Range: Defining a UDP port range for your WebRTC traffic can improve performance:
Copy code
rtc:
  udp_port: 7881
  tcp_port: 7882
  port_range_start: 50000
  port_range_end: 60000
3. Room Settings: Including default room configurations gives you better control over your sessions:
Copy code
room:
  auto_create: true
  empty_timeout: 300
  max_participants: 50
4. TURN Server: If NAT traversal is something you need, adding TURN server settings will be beneficial:
Copy code
turn:
  enabled: true
  domain: your-domain.com
  cert_file: /path/to/cert.pem
  key_file: /path/to/key.pem
5. Logging: Turning on detailed logging can really help when debugging:
Copy code
logging:
  level: debug
  json: true
If you’d like, I’m here to help you add these configurations or tailor them to your specific needs. Just let me know! Sources: pkg/config/config.go | server-sample.yaml
s
what is teh issue docker run --rm -e LIVEKIT_CONFIG="$(cat livekit.yaml)" --network host livekit/livekit-server {"level":"info","ts":1760449978.332878,"logger":"livekit","caller":"redis/redis.go:142","msg":"connecting to redis","simple":true,"addr":"http://localhost:6379"} unable to connect to redis: dial tcp: address http://localhost:6379: too many colons in address
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
s
how many agents can a 8gb. 4 core can run at a time , and how many rooms can i create