ancient-judge-59849
03/14/2026, 4:29 PMtall-airline-16756
03/14/2026, 4:29 PMtall-airline-16756
03/14/2026, 4:30 PMlk agent deploy automatically and how to tell the pipeline which LiveKit account/project to target.
Short answer
• Put your LiveKit credentials and target URL into CI/CD environment variables and the CLI will use them non-interactively.
• You can also pass them as flags to lk agent deploy if you prefer.
What to set in your pipeline
• LIVEKIT_API_KEY — your API key (store in your CI secret store).
• LIVEKIT_API_SECRET — your API secret (store in your CI secret store).
• LIVEKIT_URL — the project’s LiveKit URL (the endpoint the CLI should talk to).
How it runs in CI
1. Add the three secrets above to your CI/CD platform’s secret manager (never commit them to source).
2. In your pipeline step that runs the deploy, ensure those env vars are present. Example:
# env vars are injected by your CI; this runs headless
lk agent deploy
Or pass them explicitly:
lk agent deploy \
--api-key "$LIVEKIT_API_KEY" \
--api-secret "$LIVEKIT_API_SECRET" \
--url "$LIVEKIT_URL"
Project configuration option
• You can also keep a livekit.toml (project config) to identify the project/subdomain so the CLI knows which project to use. Credentials still must be provided via env vars or flags in headless CI.
Security notes
• Use your CI’s secret storage for LIVEKIT_API_KEY and LIVEKIT_API_SECRET.
• Do not store secrets in plaintext in the repo or pipeline logs.
If you want, tell me:
• Which CI/CD platform you’re using (GitHub Actions, GitLab, CircleCI, etc.) and I’ll give a ready-to-drop job snippet.
• Whether you prefer env-vars or explicit flags and whether you already have a livekit.toml file. Sources: Server startup modes | LiveKit Documentation | examples/drive-thru | livekit/livekit_composite | DeepWiki | Self-hosted deployments | LiveKit Documentationancient-judge-59849
03/15/2026, 11:00 PMtall-airline-16756
03/15/2026, 11:00 PMlk agent deploy fully non-interactively in your CD pipeline.
Short answer
• Yes — lk agent deploy can run without any interactive prompts if the CLI has the project config and credentials up front.
What you must provide so it runs headless
• Credentials (env vars)
Set these in your CI/CD secret store and make sure they are available to the job:
• LIVEKIT_API_KEY
• LIVEKIT_API_SECRET
• LIVEKIT_URL
The CLI reads these and won’t prompt for login.
• Agent/project config file
Ensure livekit.toml (created by lk agent create) is present in the repo or workspace. It contains the agent ID/project subdomain so lk agent deploy knows which agent to update.
• Agent secrets (if used)
If your agent needs runtime secrets, provide them ahead of time via:
• --secrets-file (e.g., a file with environment-style vars), or
• --secrets flags, or
• configure them earlier with lk agent update-secrets
That prevents prompts for secret input during deploy.
Optional flags you can use in CI
• Pass credentials and URL explicitly:
lk agent deploy \
--api-key "$LIVEKIT_API_KEY" \
--api-secret "$LIVEKIT_API_SECRET" \
--url "$LIVEKIT_URL"
• Include a secrets file:
lk agent deploy --secrets-file .env
• Set region programmatically if needed: --region <region>
Security reminders
• Never commit API keys/secrets to the repo.
• Use your CI/CD provider’s secret storage so values are injected at runtime and not printed in logs.
If you want, I can:
• Provide a ready-to-use snippet for your CI platform (GitHub Actions, GitLab CI, CircleCI, etc.).
• Review a sample job you have and suggest where to inject the env vars and how to keep secrets out of logs. Which CI are you using? Sources: Google AI and LiveKit | LiveKit Documentation | examples/drive-thru | livekit/livekit_composite | DeepWiki | Server-side | livekit/livekit_composite | DeepWiki | Agents (Python) | livekit/livekit_composite | DeepWiki | Agent deployment overview | LiveKit Documentationancient-judge-59849
03/16/2026, 1:15 AMtall-airline-16756
03/16/2026, 1:16 AMctx.job.metadata.
How to run and talk to the agent locally
• Console mode (terminal interaction): run your agent locally so you can speak/type directly in your terminal.
Example:
uv run agent.py console
This starts the agent locally and lets you interact directly.
• Dev mode (connects to cloud for browser testing): run the agent so it connects to LiveKit Cloud for real-time testing (playback from browser UI).
Example:
uv run agent.py dev
Then use the Agents Playground or a test room to join and speak to the agent in real time.
How to send job context metadata
• Metadata must be a JSON-formatted string and is available in the agent as ctx.job.metadata.
• Dispatch via the Agent Dispatch API (recommended when you control dispatch from backend):
a. Include a metadata field in the CreateAgentDispatchRequest payload:
api.CreateAgentDispatchRequest(
agent_name="my-agent",
room="my-room",
metadata='{"user_name":"Alice","user_id":"12345"}' # JSON string
)
1. Inside the agent entrypoint parse it:
metadata = json.loads(ctx.job.metadata)
user_name = metadata["user_name"]
• Dispatch via a room token (useful when issuing client tokens for joining a room):
a. Add a RoomAgentDispatch entry with metadata when building the token:
RoomAgentDispatch(agent_name="my-agent", metadata='{"user_name":"Alice"}')
1. The agent receives the metadata the same way via ctx.job.metadata.
• Self-hosted agents: include the metadata in your dispatch request body when invoking the agent.
Local testing flow examples
• Quick local dev test:
a. Ensure your local agent code can read ctx.job.metadata.
b. Run uv run agent.py dev.
c. Dispatch from your backend with metadata or create a token that includes RoomAgentDispatch metadata.
d. Join the room (or use the Agents Playground) and verify the agent received and parsed the metadata.
Notes and tips
• Keep metadata concise and JSON-serializable (strings, numbers, objects).
• If you need structured data, send a JSON object and parse it inside the agent.
• Use console mode for fast iterative testing; use dev mode + Agents Playground to test real WebRTC flows.
• Tell me whether you’re using LiveKit Cloud or a self-hosted LiveKit instance — that affects how you generate tokens and dispatch requests.
If you want, I can:
• Provide a small, runnable dispatch script for your stack (Python/Node).
• Show a sample agent entrypoint that reads and validates ctx.job.metadata.
Which would you prefer?
Sources: Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Job lifecycle | LiveKit Documentation | Agent dispatch | LiveKit Documentationancient-judge-59849
03/16/2026, 1:19 AMtall-airline-16756
03/16/2026, 1:20 AMimport asyncio
import json
from livekit import api
async def create_dispatch():
lkapi = api.LiveKitAPI() # Ensure this client is authenticated for your account
metadata_obj = {
"user_name": "Alice",
"user_id": "12345",
"intent": "support_call"
}
request = api.CreateAgentDispatchRequest(
agent_name="my-agent",
room="my-room",
metadata=json.dumps(metadata_obj) # metadata must be a JSON string
)
resp = await lkapi.agent_dispatch.create_dispatch(request)
print("Dispatch created:", resp)
await lkapi.aclose()
if __name__ == "__main__":
asyncio.run(create_dispatch())
What this does
• Creates a job that tells the deployed agent to join (or be bound to) the specified room and makes ctx.job.metadata available inside the agent as the JSON string you sent.
How you talk to the deployed agent from your local device
• You do not need to run the agent repo locally. To speak to the deployed agent, both you (the client) and the deployed agent must join the same LiveKit room.
• Typical flow:
a. Dispatch the agent (as shown above) with metadata and the target room.
b. Generate a client join token for the same room and give it to your client (browser or native app).
• The token should grant room join permissions for the room name you used in the dispatch.
• You can embed agent dispatch entries in the token instead of calling the API if you want the client to cause the agent to start when they join.
a. From your local device, use that token to connect (WebRTC) to the LiveKit room using the LiveKit SDK (browser or native). Your device will capture microphone input and send audio to the room.
b. The deployed agent will be in the room (because of the dispatch). The agent will receive audio from participants and can respond; you can hear the agent’s audio through your device.
Key points and example snippets
• Generating a simple room-join token (conceptual; adapt to your server-side token library):
from livekit import AccessToken, VideoGrants
token = (
AccessToken()
.with_identity("alice-client")
.with_grants(VideoGrants(room_join=True, room="my-room"))
.to_jwt()
)
print("Client token:", token)
• Use the LiveKit Web SDK (or native SDK) in your client to join with that token; the SDK will prompt for microphone permission and send your audio to the room.
• If you want the agent to start only when a client joins, create the token with a RoomAgentDispatch entry including metadata. That causes the agent to be dispatched as part of token usage.
Important details
• Metadata must be a JSON string; inside the agent parse it with json.loads(ctx.job.metadata).
• Ensure the dispatched room matches the room you join from your device.
• The deployed agent must be able to join the room (permissions/network) — dispatch will handle that for a LiveKit Cloud agent.
• Use secure storage for API keys and tokens; never expose admin credentials to client-side code.
If you want, I can:
• Provide a ready-to-run example showing server-side dispatch + token generation + minimal browser client code to join the room and use your microphone.
• Show a sample agent entrypoint that reads ctx.job.metadata and logs it when the agent starts.
Which would you prefer (browser client example, native mobile, or both)?ancient-judge-59849
03/16/2026, 2:59 AMtall-airline-16756
03/16/2026, 2:59 AMancient-judge-59849
03/16/2026, 3:01 AMtall-airline-16756
03/16/2026, 3:01 AMctx.job.metadata and responds with TTS.
Advanced option (if you must use Google Meet)
• Build a bridge:
◦ A headless browser or VM joins Google Meet as a participant.
◦ That device forwards Meet audio into a LiveKit room where the agent is dispatched.
◦ The agent’s TTS audio is captured and played back into Meet from the bridging device.
• Tradeoffs: higher latency, more engineering, possible Terms-of-Service concerns, fragile for demos.
Next step Which example would be most useful right now?
• A ready-to-run server script (dispatch + token generation) + minimal browser client to join and talk to the agent, or
• A sketch of the bridging prototype for Google Meet (architecture + tool suggestions)?
Tell me which one and I’ll provide the code and steps.
Sources: Agent server overview | LiveKit Documentation | Agent dispatch | LiveKit Documentation | OpenAI and LiveKit partner to turn Advanced Voice into an API | LiveKit | Gemini Realtime Agent with Live Vision | LiveKit Documentation | Yeah, but can it run DOOM? | LiveKit