i am trying to deploy a simple agent to cloud. eve...
# ask-ai
v
i am trying to deploy a simple agent to cloud. everything work on my local and I am able to talk to the agent, but I am not able to talk to the agent through a browser on the cloud. I am using the sandbox application so everything should be standard.
t
Thanks for reaching out, Michael. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! To help you better, could you please share a bit more about what’s going on? For instance: • Are you seeing any error messages in the browser or console? • Have you checked that the sandbox application URL is correct and accessible? • Did you set up the necessary environment variables like
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
, and
LIVEKIT_URL
? • Are there any logs or errors showing up during the agent deployment process? With these details, I’ll be in a much better position to understand the issue and guide you toward a solution. Looking forward to your response! Sources: livekit/livekit_cloud_agent.twirp.go | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | README.md | Sandbox | LiveKit Docs | cmd/lk/agent.go
v
so there are no logs or errors, the chat is loading, and the key, secret, url seem correct. I can even see the little microphone moving meaning its hearing something, but it never replies. I think it might be something to do with the agent_name, meaning there is no agent being added to the room? When I look at the agent I do not see a name under agent_name but I don’t know how to set it or if it’s required?
t
It looks like the issue might be because the
agent_name
isn’t set, which is really important for explicit agent dispatch. Without it, the agent might not get added to the room correctly. To fix this, you’ll want to set the
agent_name
in the
WorkerOptions
when you create your agent. Here’s a simple example to guide you:
Copy code
# Example in Python
worker_options = WorkerOptions(
    agent_name="your_agent_name"
)
After setting the
agent_name
, you can explicitly dispatch the agent to a room using the AgentDispatchService API like this:
Copy code
# Dispatch example
await lkapi.agent_dispatch.create_dispatch(
    api.CreateAgentDispatchRequest(
        agent_name="your_agent_name",
        room="your_room_name",
        metadata="optional_metadata"
    )
)
If you’d like, I’m here to help you set this up or assist with any other programming language you might be using. Just let me know! Sources: Agent dispatch | LiveKit Docs | Agents telephony integration | LiveKit Docs | examples/agent_dispatch.py | Worker options | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs
v
so in the agent.py I put the worker name? can I see it in the agent UI on my dashboard? It always shows empty but maybe I didn’t set it up correctly?
t
Absolutely, you can set the
agent_name
in your
agent.py
file, specifically within the
WorkerOptions
configuration. Once you've done that, you should be able to see the
agent_name
in the LiveKit dashboard under the Agents section. If it’s not showing up, it might mean it wasn’t configured quite right. Here’s a quick way to double-check: • Take a look at the LiveKit Agents Playground UI—it shows the configured
agent_name
along with the actual agent identity when connected. • Head over to the LiveKit Cloud dashboard under the Agents section to see the status and configuration of your deployed agents. If the
agent_name
still isn’t visible, please make sure it’s correctly set in the
WorkerOptions
and that the agent is properly deployed. I’m here to help if you want to walk through the setup together or have any other questions! Sources: Deploying to production | LiveKit Docs | Deploying to custom environments | LiveKit Docs | Agent dispatch | LiveKit Docs | src/components/playground/Playground.tsx
v
if I am using the bare agent.py, where would I add the workeroptions can you show me the full code for agent.py?
t
Here’s a full example of
agent.py
with
WorkerOptions
configured, including the `agent_name`:
Copy code
from livekit.agents import (
    Agent,
    AgentSession,
    JobContext,
    WorkerOptions,
    cli,
    function_tool,
)
from livekit.plugins import deepgram, elevenlabs, openai, silero

@function_tool
async def lookup_weather(
    context: RunContext,
    location: str,
):
    """Used to look up weather information."""
    return {"weather": "sunny", "temperature": 70}

async def entrypoint(ctx: JobContext):
    await ctx.connect()

    agent = Agent(
        instructions="You are a friendly voice assistant built by LiveKit.",
        tools=[lookup_weather],
    )
    session = AgentSession(
        vad=silero.VAD.load(),
        stt=deepgram.STT(model="nova-3"),
        llm=openai.LLM(model="gpt-4o-mini"),
        tts=elevenlabs.TTS(),
    )

    await session.start(agent=agent, room=ctx.room)
    await session.generate_reply(instructions="greet the user and ask about their day")

if __name__ == "__main__":
    cli.run_app(WorkerOptions(
        entrypoint_fnc=entrypoint,
        agent_name="your_agent_name"  # Set your agent_name here
    ))
Just a friendly reminder to replace
your_agent_name
with the name you'd like for your agent. Doing this helps your agent be clearly identified and dispatched to the right rooms without any hiccups. If you have any questions or need a hand with this setup, please don’t hesitate to reach out—I’m here to help! Sources: examples/voice_agents/resume_interrupted_agent.py | main.py | Worker options | LiveKit Docs
v
do I need session? is this a different type of room - session = AgentSession( stt=“assemblyai/universal-streaming:en”, llm=“openai/gpt-4.1-mini”, tts=“cartesia/sonic-2:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc”, vad=silero.VAD.load(), turn_detection=MultilingualModel(), ) await session.start( room=ctx.room, agent=Assistant(), room_input_options=RoomInputOptions( # For telephony applications, use
BVCTelephony
instead for best results noise_cancellation=noise_cancellation.BVC(), ), ) await session.generate_reply( instructions=“Greet the user and offer your assistance.” )
t
Absolutely!
AgentSession
is a key part of LiveKit agent deployments. Think of it as the heart that keeps everything running smoothly—it helps manage voice AI interactions by collecting user input, handling the voice pipeline, calling the LLM, and delivering responses back to the user. Here’s why the session is so important: • It sets up the models for STT, TTS, and LLM (like AssemblyAI, OpenAI, and others). • It manages workflows and coordinates how the agents interact. • It takes care of session management through
JobContext
. To give you a clearer picture, here’s an example of how you can use `AgentSession`:
Copy code
session = AgentSession(
    stt="assemblyai/universal-streaming:en",
    llm="openai/gpt-4.1-mini",
    tts="cartesia/sonic-2:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",
    vad=silero.VAD.load(),
    turn_detection=MultilingualModel(),
)

await session.start(
    room=ctx.room,
    agent=Assistant(),
    room_input_options=RoomInputOptions(
        noise_cancellation=noise_cancellation.BVC(),
    ),
)

await session.generate_reply(
    instructions="Greet the user and offer your assistance."
)
If anything feels unclear or you’d like a hand setting up your session, please don’t hesitate to reach out—I’m here to help! Sources: Building voice agents | LiveKit Docs | examples/drive-thru/test_agent.py | Models | LiveKit Docs | Template System & Example Applications | livekit/livekit_composite | DeepWi... | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki
v
I get this error 2025-10-20 203938,368 - INFO livekit.agents - shutting down worker {“id”: “unregistered”} 2025-10-20 203938,369 - DEBUG livekit.agents - shutting down job task {“reason”: “”, “user_initiated”: false} 2025-10-20 203938,370 - DEBUG livekit.agents - job exiting {“reason”: “”, “tid”: 67015993, “job_id”: “simulated-job-1c37e3c3d773"} 2025-10-20 203938,370 - DEBUG livekit.agents - http_session(): closing the httpclient ctx 2025-10-20 203938,376 - INFO livekit.agents - process exiting {“reason”: “”, “pid”: 75116, “inference”: true} 2025-10-20 203939,172 - ERROR asyncio - Task exception was never retrieved future: <Task finished name=‘Task-27’ coro=<ConnectionPool.prewarm.<locals>._prewarm_impl() done, defined at /Users/michaels/Apps/kora_agents/kora-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/connection_pool.py:163> exception=WSServerHandshakeError(RequestInfo(url=URL(‘wss://agent-gateway.livekit.cloud/v1/tts’), method=‘GET’, headers=<CIMultiDictProxy(‘Host’: ‘agent-gateway.livekit.cloud’, ‘Authorization’: ‘Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbmZlcmVuY2UiOnsicGVyZm9ybSI6dHJ1ZX0sInN1YiI6ImFnZW50IiwiaXNzIjoiZmFrZV9jb25zb2xlX2tleSIsIm5iZiI6MTc2MTAxNzk1OSwiZXhwIjoxNzYxMDE4NTU5fQ.4kpX1JDae7vgXVqF8Go95g0PfWwSFXzIx94Ecq0irL8’, ‘Upgrade’: ‘websocket’, ‘Connection’: ‘Upgrade’, ‘Sec-WebSocket-Version’: ‘13’, ‘Sec-WebSocket-Key’: ‘CgezTZsnNcjT/qDhg8URww==’, ‘Accept’: ‘*/*’, ‘Accept-Encoding’: ‘gzip, deflate’, ‘User-Agent’: ‘Python/3.13 aiohttp/3.13.1’)>, real_url=URL(’wss://agent-gateway.livekit.cloud/v1/tts')), (), status=401, message=‘Invalid response status’, headers=<CIMultiDictProxy(‘Content-Length’: ‘22’, ‘Content-Type’: ‘text/plain; charset=utf-8’, ‘Date’: ‘Tue, 21 Oct 2025 033920 GMT’)>)> Traceback (most recent call last): File “/Users/michaels/Apps/kora_agents/kora-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/connection_pool.py”, line 165, in _prewarm_impl conn = await self._connect(timeout=self._connect_timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/michaels/Apps/kora_agents/kora-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/connection_pool.py”, line 61, in _connect connection = await self._connect_cb(timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/michaels/Apps/kora_agents/kora-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/tts.py”, line 290, in _connect_ws ws = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ session.ws_connect(f”{base_url}/tts”, headers=headers), timeout ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File “/usr/local/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/tasks.py”, line 507, in wait_for return await fut ^^^^^^^^^ File “/Users/michaels/Apps/kora_agents/kora-agent/.venv/lib/python3.13/site-packages/aiohttp/client.py”, line 1100, in _ws_connect raise WSServerHandshakeError( ...<5 lines>... ) aiohttp.client_exceptions.WSServerHandshakeError: 401, message=‘Invalid response status’, url=‘wss://agent-gateway.livekit.cloud/v1/tts’
t
It looks like you're encountering an authentication error (401 Unauthorized) when your agent tries to connect to the TTS service. This usually means there might be a small hiccup with the API key, secret, or environment setup. Let’s work through this together with a few simple steps: 1. Verify Environment Variables: Please double-check that these are set correctly:
LIVEKIT_API_KEY=your_api_key
LIVEKIT_API_SECRET=your_api_secret
LIVEKIT_INFERENCE_URL=https://agent-gateway.livekit.cloud/v1
2. Check API Key and Secret: Make sure your API key and secret are accurate, active, and have the right permissions for TTS inference. 3. Validate TTS Configuration: Confirm that the TTS service is properly configured to use the credentials. The WebSocket connection relies on a Bearer token generated from your API key and secret. 4. Connection URL: Verify that the WebSocket URL is exactly
wss://agent-gateway.livekit.cloud/v1/tts
. If you’re still seeing the issue after these checks, it might be helpful to look at your network connectivity to the LiveKit inference gateway and ensure nothing like firewall rules is blocking WebSocket connections. Please feel free to reach out if you’d like me to guide you through any of these steps—I’m here to help! Sources: Core Platform Architecture & Authentication | livekit/livekit_composite | D... | livekit-agents/livekit/agents/voice/agent.py | Voice Assistant Applications | livekit/livekit_composite | DeepWiki | Events and error handling | LiveKit Docs
v
ok so its working now, is this agent.py good does it have the agent_name defined correctly - from dotenv import load_dotenv from livekit import agents from livekit.agents import AgentSession, Agent, RoomInputOptions, JobContext, WorkerOptions from livekit.plugins import noise_cancellation, silero from livekit.plugins.turn_detector.multilingual import MultilingualModel load_dotenv(“.env.local”) class Assistant(Agent): def __init__(self) -> None: super().__init__( instructions=“”"You are a helpful voice AI assistant. You eagerly assist users with their questions by providing information from your extensive knowledge. Your responses are concise, to the point, and without any complex formatting or punctuation including emojis, asterisks, or other symbols. You are curious, friendly, and have a sense of humor.“”", ) async def entrypoint(ctx: agents.JobContext): session = AgentSession( stt=“assemblyai/universal-streaming:en”, llm=“openai/gpt-4.1-mini”, tts=“cartesia/sonic-2:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc”, vad=silero.VAD.load(), turn_detection=MultilingualModel(), ) await session.start( room=ctx.room, agent=Assistant(), room_input_options=RoomInputOptions( # For telephony applications, use
BVCTelephony
instead for best results noise_cancellation=noise_cancellation.BVC(), ), ) await session.generate_reply( instructions=“Greet the user and offer your assistance.” ) if name == “__main__“: agents.cli.run_app(agents.WorkerOptions( entrypoint_fnc=entrypoint, agent_name=“kora-voice-agent” ))
t
Your
agent.py
script looks really well put together and includes all the important pieces for a smooth LiveKit agent deployment. I see that the
agent_name
is thoughtfully set in the
WorkerOptions
as
"kora-voice-agent"
, which is great because it helps the agent get dispatched to rooms just as you want. Let’s take a quick look at the main parts: • Agent Definition: The
Assistant
class is nicely defined with clear guidance on how the agent should behave. • Session Configuration: Your
AgentSession
is set up with STT, LLM, TTS, VAD, and turn detection — all the essentials for a voice AI to work smoothly. • Entrypoint: The
entrypoint
function is doing its job well by initializing the session, starting it with the agent and room, and then generating a reply. • WorkerOptions: Having the
agent_name
as
"kora-voice-agent"
is spot on for explicit dispatch and keeping things clear in the LiveKit dashboard. Everything seems to be set up just right! If you have any questions or want to explore adding more features to your agent, please don’t hesitate to reach out. I’m here to help!
v
ok so from here I should say lk agent create? do I need to add the name somewhere in config or something or when I create it to the cloud i should see the agent_name in the agent UI on the dashboard
t
I'm happy to help you get your agent deployed to the cloud and make sure the
agent_name
shows up in your dashboard. Just follow these simple steps: 1. Start by Navigating to Your Project Directory:
cd your-agent-project
2. Next, Authenticate with LiveKit Cloud:
lk project auth
This step connects your CLI to your LiveKit Cloud project so everything syncs smoothly. 3. Then, Create and Deploy Your Agent:
lk agent create
This will register your agent, give it a unique ID, and deploy it to the cloud. If you want to set a specific name, just add it like this:
lk agent create "kora-voice-agent"
4. Finally, Monitor Your Deployment: You can keep an eye on how things are going with these commands:
lk agent status
lk agent logs
After you’ve done this, your agent will show up in the LiveKit Cloud dashboard under the Agents section with the
agent_name
you chose. If you have any questions or need a hand along the way, just let me know—I’m here to help! Sources: Deploying to production | LiveKit Docs | CLI Tools & Token Management | livekit/livekit_composite | DeepWiki | protobufs/livekit_cloud_agent.proto
v
if i say lk agent create “kora-voice-agent” will that set the agent name or is the workeroptions what’s setting the agent name? what is the meaning of adding something after agent create
t
Thanks for reaching out! I’d love to help clarify the difference between the
agent_name
in
WorkerOptions
and the name you specify with
lk agent create
. They actually serve different but complementary purposes: • `WorkerOptions agent_name`: This is used when you want to explicitly dispatch an agent within your application. It helps you target specific agents for rooms or tasks. For example, if you set
agent_name="kora-voice-agent"
in
WorkerOptions
, it means this agent can be directly dispatched using the API or access tokens. • `lk agent create [AGENT-NAME]`: This CLI command is for deploying your agent to LiveKit Cloud. The name you provide here identifies the agent deployment in the cloud and on your dashboard, but it doesn’t affect how dispatch works inside your application. In practice, you’ll want to use both: 1. Set
agent_name
in
WorkerOptions
to control explicit dispatch. 2. Use
lk agent create "kora-voice-agent"
to deploy your agent to the cloud and have it show up on your dashboard. If anything feels unclear or you’d like a hand setting this up, please don’t hesitate to ask—I’m here to help! Sources: examples/other/translation/multi-user-translator.py | Agent dispatch | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | cmd/lk/agent.go | CLI Tools & Token Management | livekit/livekit_composite | DeepWiki
v
oops looks like we missed a step I get this error - Creating new agent Using secrets file [.env.local] Detected project type [unknown] unable to determine project type: project type could not be identified; expected package.json, requirements.txt, pyproject.toml, or lock files, please use a supported project type, or create your own Dockerfile in the current directory
t
It looks like the error happened because the
lk agent create
command couldn’t automatically detect your project type. It tries to find certain files that tell it whether your project is based on Python or Node.js. Don’t worry, here’s a simple way to fix this: 1. Add the Required Manifest Files: ◦ If you’re working with a Python project, please add one of these files to your working directory:
requirements.txt
,
pyproject.toml
,
poetry.lock
, or
Pipfile.lock
. ◦ If it’s a Node.js project, just make sure you have a
package.json
file there. 1. Use a Custom Dockerfile: If you’d rather not rely on automatic detection, you can create a
Dockerfile
inside your project directory. The CLI will then use that instead of trying to guess your project type. 2. Generate a Dockerfile: After adding the necessary files, you can create a Dockerfile by running:
lk agent dockerfile [working-dir] --overwrite
Once you have these files set up, please try running the
lk agent create
command again. If you run into any more issues or have questions, I’m here to help! Sources: pkg/agentfs/utils.go | CLI Tools & Token Management | livekit/livekit_composite | DeepWiki
v
when I just run lk agent create it works but if i write lk agent create “kora” it does not work and I get this error - michaels@MacBook-Pro-6 kora-assistant % lk agent create “kora-assistant” Using default project [kora] Creating new agent Using secrets file [.env.local] Detected project type [unknown] unable to determine project type: project type could not be identified; expected package.json, requirements.txt, pyproject.toml, or lock files, please use a supported project type, or create your own Dockerfile in the current directory I have pyrpoject.toml in the directory and even if I generate a dockerfile it does not work
t
I understand how this can be a bit confusing! The
lk agent create
command actually expects a working directory path as its argument, not an agent name. So, when you enter something like
"kora-assistant"
, the CLI thinks it’s a directory path and will run into trouble if that directory doesn’t exist or isn’t set up correctly. Let me guide you through the steps to fix this: 1. Use the Correct Command: Try running
lk agent create
without any arguments to create the agent right in your current directory:
lk agent create
Or, if you prefer, specify the exact directory path like this:
lk agent create /path/to/your/project
2. Check for Existing
livekit.toml
File:
If you already have a
livekit.toml
file in that directory, you can either remove it or use
lk agent deploy
instead to update your agent. 3. Make Sure Required Files Are Present: Your project should include important files like
pyproject.toml
,
requirements.txt
, or a
Dockerfile
so the CLI can detect and set things up properly. After you create the agent, the CLI will take care of generating a
livekit.toml
file with the agent ID for you. If anything feels unclear or you want me to walk you through any part, just let me know—I’m here to help! Sources: autocomplete/fish_autocomplete | Agent deployment CLI reference | LiveKit Docs | CLI Tools & Token Management | livekit/livekit_composite | DeepWiki