straight-greece-72452
12/04/2025, 7:47 AMtall-airline-16756
12/04/2025, 7:47 AMtall-airline-16756
12/04/2025, 7:48 AMlk agent create) and customers do not get direct OS/container shell access.
If you need to run custom code or troubleshoot, I can help with alternatives—e.g., deploying an agent, adding logging, or running diagnostic code inside your deployment. Which approach do you want to try?
Sources: LiveKit Cloud | LiveKit Docs | Deploying to production | LiveKit Docsstraight-greece-72452
12/04/2025, 7:55 AMtall-airline-16756
12/04/2025, 7:55 AMngrok http 3000.
• Host the service publicly: deploy the service to a cloud VM/container (Render, Fly.io, etc.) and call its public domain or IP from the agent.
• Run the agent where the service is reachable: deploy the agent to an environment that can access your service (self-hosted agent or same VPC/network).
Notes on implementation:
• From the agent, call the public URL with standard HTTP libraries or define it as an HTTP tool in Agent Builder.
• Store any credentials or API keys using LiveKit secrets features so they aren’t hard-coded.
Which option fits your setup best (tunnel, public hosting, or self-hosted agent)? I can give step-by-step commands for the one you pick.
Sources: https://blog.livekit.io/announcing-agent-builder-a-pathway-to-code/#/portal/signup| | Deploying to custom environments | LiveKit Docs | Zscaler proxy configuration | Log collection | LiveKit Docsstraight-greece-72452
12/04/2025, 7:59 AMtall-airline-16756
12/04/2025, 7:59 AMstraight-greece-72452
12/04/2025, 8:08 AMtall-airline-16756
12/04/2025, 8:08 AMstraight-greece-72452
12/04/2025, 8:11 AMtall-airline-16756
12/04/2025, 8:12 AMhttpx from your agent logic:
# agent.py
from fastapi import FastAPI
import uvicorn
import threading
import asyncio
import httpx
from livekit import cli, JobContext, WorkerOptions # adjust imports to your SDK
app = FastAPI()
@app.post("/process")
async def process(payload: dict):
return {"processed": payload.get("input", "") + " -> ok"}
def run_server():
uvicorn.run(app, host="0.0.0.0", port=8000)
async def entrypoint(ctx: JobContext):
thread = threading.Thread(target=run_server, daemon=True)
thread.start()
await asyncio.sleep(0.5) # allow server to start
async with httpx.AsyncClient() as client:
r = await client.post("http://localhost:8000/process", json={"input":"hello"})
await ctx.room.local_participant.publish_data(r.json())
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Node.js (Express + fetch)
1. Add dep: express.
2. Start Express before/inside the agent entrypoint and call `http://localhost:8000`:
// agent.ts
import express from "express";
import { defineAgent, JobContext } from "@livekit/agents"; // adjust as needed
const app = express();
app.use(express.json());
app.post("/process", (req, res) => {
res.json({ processed: `${req.body.input} -> ok` });
});
app.listen(8000, () => console.log("HTTP service on :8000"));
export default defineAgent({
entry: async (ctx: JobContext) => {
const res = await fetch("http://localhost:8000/process", {
method: "POST",
headers: {"Content-Type":"application/json"},
body: JSON.stringify({ input: "hello" }),
});
const json = await res.json();
await ctx.room.localParticipant.publishData(JSON.stringify(json));
},
});
Dockerfile note
• EXPOSE the port (e.g., 8000) in your Dockerfile. Internal localhost calls do not require external routing.
Key benefits and constraints
• Benefits: near-zero latency (calls over localhost), no public tunnel, tight coupling for latency-sensitive logic.
• Constraints: the HTTP service is internal to the agent container — not reachable from outside LiveKit Cloud unless you host it separately or self-host the agent.
Next step Which runtime are you using for your agent (Python or Node), and do you want a minimal example repo or Dockerfile snippets for deployment? I can provide those next.
Sources: Voice AI quickstart | LiveKit docs | Deploying to production | LiveKit Docs | Agent server | LiveKit docsstraight-greece-72452
12/04/2025, 8:17 AMtall-airline-16756
12/04/2025, 8:17 AMthreading.Thread(target=run_server, daemon=True)), so the service binds to 0.0.0.0:8000 inside the container and the agent calls it at http://localhost:8000.
• Node example: Express is started in the same process before the agent's entrypoint runs (app.listen(8000)), so the agent calls http://localhost:8000.
Because both server and agent share the same container, calls go over localhost (near-zero latency) and the service is not externally exposed unless you explicitly publish the port or deploy the service separately.straight-greece-72452
12/04/2025, 9:28 AMtall-airline-16756
12/04/2025, 9:28 AMrun_server and how it integrates with the agent for the Python example.
Python (FastAPI + Uvicorn) — full focused snippet:
from fastapi import FastAPI
import uvicorn
import threading
import asyncio
import httpx
from livekit import cli, JobContext, WorkerOptions # adjust to your SDK
app = FastAPI()
@app.post("/process")
async def process(payload: dict):
return {"processed": payload.get("input", "") + " -> ok"}
def run_server():
# This blocks while running the ASGI server; run it in a daemon thread
uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")
async def entrypoint(ctx: JobContext):
# Start the HTTP server in a background thread so it doesn't block the agent
thread = threading.Thread(target=run_server, daemon=True)
thread.start()
# Optionally wait a short time for the server to be ready
await asyncio.sleep(0.5)
# Agent calls the local service over localhost
async with httpx.AsyncClient() as client:
r = await client.post("http://localhost:8000/process", json={"input": "hello"})
await ctx.room.local_participant.publish_data(r.json())
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Key points:
• run_server calls uvicorn.run(...), which starts the ASGI loop and blocks — that's why we start it in a daemon thread.
• The agent's logic runs in the async `entrypoint`; it can call http://localhost:8000 with minimal latency.
• Keep the thread daemonized so it won't prevent graceful shutdown of the agent process.
• If you prefer fully async, you can run Uvicorn programmatically with uvicorn.Server and asyncio.create_task instead of threads.
Want the programmatic async version example next, or a Node.js equivalent?