Business-facing Lampgo LiveKit Agent SDK.
Project description
Lampgo LiveKit Agent SDK
Business-facing SDK for the Lampgo LiveKit RTC + Agent stack.
Full Chinese usage guide in this repository: ../docs/xiaomi-livekit-agent-sdk/usage.md.
It wraps:
- LiveKit token generation with internal
RoomAgentDispatch. voice_agents[].name -> agent_namemapping.- FastAPI
/rtc/tokenand/healthzroutes. - Parent process supervision for one HTTP token process plus one Agent Worker process per voice agent.
- LiveKit Agents runtime with Silero VAD, OpenAI-compatible LLM, and Volcengine STT/TTS.
Install
From public PyPI:
pip install lampgo-livekit-agent-sdk
For local development from the repository root:
pip install -e ./xiaomi-livekit-agent-sdk
The Volcengine STT/TTS plugin is bundled in this SDK wheel, so business users do not
install livekit-plugins-volcengine separately.
Both local mode (
livekit.api_key+livekit.api_secret) and cloud mode (platform.*+agent.registration_token) work on the public PyPI install. For cloud mode on the publiclivekit-agents, the SDK adds external agent-token support at runtime, so no internal index or patched framework is required.
Single Config File
The SDK uses one YAML file by default: roles.yaml.
The file now describes concrete voice agents. Each voice agent directly configures how it listens (stt), thinks (llm), and speaks (tts):
version: 1
livekit:
url: ${LIVEKIT_URL}
api_key: ${LIVEKIT_API_KEY}
api_secret: ${LIVEKIT_API_SECRET}
token_api:
shared_secret: ${TOKEN_API_SHARED_SECRET:-}
ttl_seconds: 600
min_ttl_seconds: 60
max_ttl_seconds: 3600
agent:
name_prefix: lampgo-agent
providers:
openai_internal:
type: openai
api_key: ${OPENAI_API_KEY}
base_url: ${OPENAI_BASE_URL}
volc_main:
type: volcengine
app_id: ${VOLCENGINE_APP_ID}
access_token: ${VOLCENGINE_ACCESS_TOKEN}
defaults:
stt:
provider: volc_main
options:
resource_id: volc.bigasr.sauc.duration
sample_rate: 16000
result_type: single
llm:
provider: openai_internal
options:
model: xiaomi/mimo-v2-flash
temperature: 0.3
max_tokens: 512
tts:
provider: volc_main
options:
cluster: volcano_tts
voice: BV700_streaming
sample_rate: 24000
streaming: true
voice_agents:
- name: customer-service
display_name: "小米客服助手"
llm:
system_prompt: "你是小米客服助手,用中文简短回答用户问题,不要使用 Markdown 或表情符号。"
llm.system_prompt is the model system prompt. For longer prompts, use:
voice_agents:
- name: customer-service
llm:
system_prompt_file: ./prompts/customer-service.md
If token_api.shared_secret is set, /rtc/token requires:
Authorization: Bearer <shared bearer secret>
An empty token_api.shared_secret disables token API bearer auth for local/LAN testing.
If a token request sends ttl_seconds, the server clamps it to the configured min/max range.
Environment variables are only used when the YAML explicitly references them, for example ${OPENAI_API_KEY} or ${TOKEN_API_SHARED_SECRET:-}.
Voice Agents
The SDK maps each configured voice agent to an internal LiveKit agent_name.
Default generated agent name:
{agent.name_prefix or "lampgo-agent"}-{voice_agent_name_slug}
The public token API never returns agent_name.
Run
lampgo-livekit-agent --config-file roles.yaml --host 0.0.0.0 --port 8080
Equivalent Python entry point:
from lampgo_livekit_agent import LiveKitAgentConfig, start_service
start_service(config=LiveKitAgentConfig.from_env(config_file="roles.yaml"))
Token API
For compatibility, the request field is still named role; it selects voice_agents[].name.
Request:
curl -X POST http://127.0.0.1:8080/rtc/token \
-H 'Content-Type: application/json' \
-d '{
"room_name": "room-001",
"user_identity": "user-001",
"role": "customer-service",
"metadata": {"tenant_id": "business-a"}
}'
The new voice_agent field is also accepted:
{
"room_name": "room-001",
"user_identity": "user-001",
"voice_agent": "customer-service"
}
Response:
{
"token": "...",
"serverUrl": "ws://192.168.31.116:7880",
"roomName": "room-001",
"identity": "user-001",
"role": "customer-service"
}
The JWT contains:
RoomConfiguration(
agents=[RoomAgentDispatch(agent_name="<internal voice agent agent_name>")]
)
FastAPI Integration
For an existing business FastAPI application:
from fastapi import FastAPI
from lampgo_livekit_agent import LiveKitAgentConfig
from lampgo_livekit_agent.fastapi import mount_livekit_routes
app = FastAPI()
config = LiveKitAgentConfig.from_env(config_file="roles.yaml")
mount_livekit_routes(app, config=config)
Business services remain responsible for user authentication and room/tenant authorization.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lampgo_livekit_agent_sdk-0.3.0.tar.gz.
File metadata
- Download URL: lampgo_livekit_agent_sdk-0.3.0.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b42924c6c27fa90955694a6b453d497fceb4bf8c2ce560a043a671d6fc3d8d27
|
|
| MD5 |
f15cec7cff5f53b325b831d95a5a75b8
|
|
| BLAKE2b-256 |
f149974d303b514fb93c171371b1ee4afde5946983805e72259242d76c481a3c
|
File details
Details for the file lampgo_livekit_agent_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: lampgo_livekit_agent_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 40.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6434f37d037a51aa8bb60bdf64bc56ff9ebcbcf27a65031de2b141d1655fbe21
|
|
| MD5 |
ce13e1101e93b0ff5da6bfbe2b5f93b8
|
|
| BLAKE2b-256 |
4e262124d08b77a795d2418920c8b8d1a6d690a45e6a181bf0e6fe4a9434ff5f
|