Skip to main content

streamlit-livekit

Talk to a LiveKit voice agent from a Streamlit app, in real time.

voice_agent() is a Streamlit custom component (v2). It renders:

  • Start and End buttons plus a Mute button.
  • Audio meters for you and for the agent, along with the agent's state (listening, thinking, speaking).
  • A live transcript.

It follows the app's light, dark, or custom theme.

Audio streams directly between the browser and LiveKit through livekit-client. Python only creates the access token. That token dispatches your agent to a fresh room for each conversation.

Installation

pip install streamlit-livekit

It needs Python 3.10+ and Streamlit 1.51+. You also need a LiveKit Cloud project (or a self-hosted LiveKit server) and an agent built with LiveKit Agents.

Usage

import streamlit as st
from streamlit_livekit import voice_agent

result = voice_agent("my-agent")  # the agent_name your agent registers with

st.write(result.state)  # "idle" | "connecting" | "connected" | "ended"
st.write(result.transcript)  # [{"role": "user" | "agent", "text": "..."}]

# Let the user save the conversation
st.download_button("Export transcript", result.to_text(), file_name="transcript.txt")

Credentials come from LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET, or from the url, api_key, and api_secret arguments.

Talking to an agent on your machine

lk agent dev registers under a random dev-... deployment unless you name one. Name it, and pass the same name to voice_agent():

lk agent dev --deployment local-dev
voice_agent("my-agent", deployment="local-dev")

Leave deployment empty to reach the production deployment on LiveKit Cloud.

Passing context to your agent

Send anything the agent should know as metadata, such as the user's name, a persona picked in the sidebar, or the app's settings:

name = st.text_input("Your name")
persona = st.selectbox("Persona", ["Friendly", "Concise", "Pirate"])

voice_agent("my-agent", metadata={"user_name": name, "persona": persona})

The dict goes to the agent as JSON job metadata when a conversation starts. Read it in the agent's entrypoint:

import json


@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
    context = json.loads(ctx.job.metadata or "{}")
    user_name = context.get("user_name")
    ...

Metadata is fixed when a conversation's room is created, because that's when LiveKit dispatches the agent. If it changes while the panel is idle, the panel switches to a fresh token right away. If it changes during or after a conversation, the live call is left alone and the new value applies to the next conversation.

LiveKit simulations can't set job metadata. To keep an agent that reads it testable, put the same values in the scenario's userdata and read them from ctx.simulation_context() during a simulation.

API

voice_agent(agent_name, *, deployment="", metadata=None, url=None, api_key=None, api_secret=None, room_prefix="streamlit", token_ttl=timedelta(minutes=15), key="voice_agent")

It returns a VoiceAgentResult with these fields:

Field / method Description
state "idle", "connecting", "connected", or "ended"
transcript Final lines so far, as [{"role": "user" | "agent", "text": ...}]
room The LiveKit room for the current conversation
to_text() The transcript as plain text, one You: or Agent: line per turn

Each conversation gets its own room, because LiveKit only dispatches an agent when a room is created. The panel's "New conversation" button asks Python for a fresh room and token.

Example app

example/streamlit_app.py is a complete page with transcript export. Copy example/.streamlit/secrets.toml.example to secrets.toml, fill in your LiveKit credentials, start your agent, and run:

cd example
streamlit run streamlit_app.py

Development

git clone https://github.com/dataprofessor/streamlit-livekit
cd streamlit-livekit
uv sync
uv run streamlit run example/streamlit_app.py

The component lives in streamlit_livekit/: the Python API is in __init__.py, and the browser side is in frontend/ (HTML, CSS, and JS). Streamlit serves the CSS and JS from the asset_dir declared in streamlit_livekit/pyproject.toml. It picks up JS and CSS edits on reload, but changes to the Python code need a restart of streamlit run.

Run the tests with uv run pytest, and format and lint with uv run ruff format and uv run ruff check.

Releasing

Publishing a GitHub release publishes the package to PyPI through .github/workflows/publish.yml, using trusted publishing, so no API token is stored. To release:

  1. Bump version in pyproject.toml (or run uv version --bump patch), and commit.

  2. Publish a GitHub release tagged with that version and a leading v, e.g. v0.1.1:

    gh release create v0.1.1 --generate-notes
    

The workflow fails without publishing if the tag doesn't match the version.

Notes

  • The browser loads livekit-client from jsDelivr the first time you start a conversation.
  • Microphone access needs a secure context: localhost or HTTPS.
  • result.transcript gets only final lines, so Streamlit doesn't rerun on every partial word. The panel itself shows the partial words as they arrive.

License

MIT

Metadata

Release files for streamlit-livekit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-livekit 0.1.1
File Size Uploaded Provenance Actions
streamlit_livekit-0.1.1.tar.gz 16.2 kB With provenance Details for streamlit_livekit-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-livekit 0.1.1
File Interpreter ABI Platform Actions
streamlit_livekit-0.1.1-py3-none-any.whl Python 3 none any Details for streamlit_livekit-0.1.1-py3-none-any.whl

Total release size: 30.5 kB

Release files / streamlit_livekit-0.1.1.tar.gz

Download URL streamlit_livekit-0.1.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
20461bcaf8092b2a913588edd2308a88a79a3195eddc4cd2675b0120d6ec8c22
BLAKE2b-256 checksum
How to use checksums
f7a692a125667470fae1f1c25e0cdb9eab0f8e923aff2ac2c38e3c21997752e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / streamlit_livekit-0.1.1-py3-none-any.whl

Download URL streamlit_livekit-0.1.1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85e91374accfb5e8e2bedb564c1f2cb8bffa4b3a31227936bd565385ebafbfea
BLAKE2b-256 checksum
How to use checksums
fa292d3aefdafa41b02b3bc40e94eab6b5f101a600fe9fab9f1a5f2221c1f9dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for streamlit-livekit 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for streamlit_livekit-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page