livekit.agents._exceptions.APIStatusError: Server ...
# ask-ai
t
livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=400, request_id=None, body={"detail":"No LiveKit env found for model"}, retryable=False) ⚠️ .env file not found at: /app/.env 2025-11-24 110310 [WARNING] livekit.plugins.silero: padding_duration is deprecated and will be removed in 1.5.0, use prefix_padding_duration instead 2025-11-24 110310 [WARNING] livekit.plugins.silero: padding_duration is deprecated and will be removed in 1.5.0, use prefix_padding_duration instead {"message": "padding_duration is deprecated and will be removed in 1.5.0, use prefix_padding_duration instead", "level": "WARNING", "name": "livekit.plugins.silero", "pid": 24870, "timestamp": "2025-11-24T110310.796849+00:00"} 2025-11-24 110310 [INFO] livekit.agents: process initialized {"message": "process initialized", "level": "INFO", "name": "livekit.agents", "pid": 24870, "elapsed_time": 0.58, "timestamp": "2025-11-24T110310.871430+00:00"} 2025-11-24 110310 [DEBUG] asyncio: Using selector: EpollSelector 2025-11-24 110313 [ERROR] livekit.plugins.bey: failed to call bey presence api Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py", line 134, in _start_agent raise APIStatusError( livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=500, request_id=None, body=Internal Server Error, retryable=True) 2025-11-24 110313 [ERROR] livekit.plugins.bey: failed to call bey presence api Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py", line 134, in _start_agent raise APIStatusError( livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=500, request_id=None, body=Internal Server Error, retryable=True) {"message": "failed to call bey presence api\nTraceback (most recent call last):\n File \"/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py\", line 134, in _start_agent\n raise APIStatusError(\nlivekit.agents._exceptions.APIStatusError: Server returned an error (status_code=500, request_id=None, body=Internal Server Error, retryable=True)", "level": "ERROR", "name": "livekit.plugins.bey", "room": "interview-a827c2bd-d101-4650-b401-58d08bb5dc26-1763982189", "pid": 18248, "job_id": "AJ_fh8m36x5kWHF", "timestamp": "2025-11-24T110313.019395+00:00"} 2025-11-24 110318 [ERROR] livekit.plugins.bey: failed to call bey presence api Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py", line 134, in _start_agent raise APIStatusError( livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=400, request_id=None, body={"detail":"Secret 'MODEL_LIVEKIT_ENVS' not found. Please set it either as an environment variable or add it in Google Secret Manager."}, retryable=False) 2025-11-24 110318 [ERROR] livekit.plugins.bey: failed to call bey presence api Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py", line 134, in _start_agent raise APIStatusError( livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=400, request_id=None, body={"detail":"Secret 'MODEL_LIVEKIT_ENVS' not found. Please set it either as an environment variable or add it in Google Secret Manager."}, retryable=False) {"message": "failed to call bey presence api\nTraceback (most recent call last):\n File \"/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py\", line 134, in _start_agent\n raise APIStatusError(\nlivekit.agents._exceptions.APIStatusError: Server returned an error (status_code=400, request_id=None, body={\"detail\":\"Secret 'MODEL_LIVEKIT_ENVS' not found. Please set it either as an environment variable or add it in Google Secret Manager.\"}, retryable=False)", "level": "ERROR", "name": "livekit.plugins.bey", "room": "interview-a827c2bd-d101-4650-b401-58d08bb5dc26-1763982189", "pid": 18248, "job_id": "AJ_fh8m36x5kWHF", "timestamp": "2025-11-24T110318.606717+00:00"} 2025-11-24 110320 [WARNING] livekit.agents: The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. {"message": "The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. ", "level": "WARNING", "name": "livekit.agents", "room": "interview-a827c2bd-d101-4650-b401-58d08bb5dc26-1763982189", "pid": 18248, "job_id": "AJ_fh8m36x5kWHF", "timestamp": "2025-11-24T110320.564196+00:00"} 2025-11-24 110320 [WARNING] livekit.agents: The room connection was not established within 10 seconds after calling job_entry. This may indicate that job_ctx.connect() was not called. 2025-11-24 110324 [ERROR] livekit.plugins.bey: failed to call bey presence api Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/livekit/plugins/bey/avatar.py", line 134, in _start_agent raise APIStatusError( livekit.agents._exceptions.APIStatusError: Server returned an error (status_code=400, request_id=None, body={"detail":"Secret 'MODEL_LIVEKIT_ENVS' not found. Please set it either as an environment variable or add it in Google Secret Manager."}, retryable=False) 2025-11-24 110324 [ERROR] agent: Failed to start Beyond Presence avatar session: Failed to start Bey Avatar Session after all retries (body=None, retryable=True) 2025-11-24 110324 [INFO] agent: 📋 Registering room event handlers (participant_connected, participant_disconnected) what is this issue I am facing ? and how to fix it ?
t
Thanks for reaching out, Om. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I see three related problems in your logs: missing LiveKit environment configuration (including the
MODEL_LIVEKIT_ENVS
secret), a missing
.env
file, and a deprecation + room-connection warning. Here’s how to fix each quickly. What’s happening (summary) • The agent cannot find LiveKit connection settings, causing:
No LiveKit env found for model
and the APIStatusError. • The process warns
.env
is not found at /app/.env, so environment variables expected at startup are not loaded. • The Bey plugin specifically expects a secret named
MODEL_LIVEKIT_ENVS
(missing). •
padding_duration
is deprecated (warning only). • The agent also warns the room connection wasn’t established within 10s — usually because
job_ctx.connect()
wasn’t called early or the agent failed to authenticate due to missing envs. Immediate fixes (do these in order) 1. Create/load a .env (for local/dev) or inject env vars in your deployment: ◦ Add at least: ▪︎ LIVEKIT_URL=<your_livekit_url> ▪︎ LIVEKIT_API_KEY=<your_api_key> ▪︎ LIVEKIT_API_SECRET=<your_api_secret> 1. Provide the
MODEL_LIVEKIT_ENVS
secret expected by the Bey plugin: ◦ Option A — environment variable (quick test / local): ▪︎ In
.env
set: MODEL_LIVEKIT_ENVS={"LIVEKIT_URL":"wss://...","LIVEKIT_API_KEY":"...","LIVEKIT_API_SECRET":"..."} • Option B — cloud secret (production): ◦ Add
MODEL_LIVEKIT_ENVS
into your secret manager (e.g., Google Secret Manager) with the same JSON payload and ensure the service account has access. 1. If using LiveKit agent CLI to update secrets in deployed agents, use the agent CLI to inject secrets (example pattern): ◦ lk agent update-secrets --secrets "LIVEKIT_URL=..." --secrets "LIVEKIT_API_KEY=..." --secrets "LIVEKIT_API_SECRET=..." (Use your deployment’s specific CLI/secret workflow to add
MODEL_LIVEKIT_ENVS
similarly.) 1. Replace deprecated parameter: ◦ Update any Silero VAD config using
padding_duration
to
prefix_padding_duration
to remove the warning. 1. Ensure the agent connects to the room early: ◦ Call
await job_ctx.connect()
(or equivalent) early in your job handler so the room connection is established within the expected timeout. Quick verification steps • Restart the agent process after adding envs/secrets. • Confirm logs no longer show the
No LiveKit env found for model
or
Secret 'MODEL_LIVEKIT_ENVS' not found
errors. • Confirm room connection succeeds (no 10s warning). If you want, tell me: • Whether you’re running locally or in GCP/k8s/LiveKit Cloud, and • The exact format you prefer to store the secret (env var JSON vs separate LIVEKIT_* vars), and I’ll give the exact commands/snippet to add the secret for that environment. Sources: Secrets management | LiveKit Docs | Company directory phone assistant | LiveKit Docs | Next.js quickstart | LiveKit docs | Agent deployment CLI reference | LiveKit docs | Deploying to custom environments | LiveKit Docs
t
but anam avatars are working, with the same setup, only beyond presence ones are failing this is my .env creds : LIVEKIT_URL="wss://test1-jl42sr5y.livekit.cloud" LIVEKIT_API_KEY="API52yNX8hMFCRF" LIVEKIT_API_SECRET="BaaP0KlLzyQohEO80inKnEB1fDyI66kB59IYGdHxxdAQ"
t
Thanks — helpful detail. You're right to note Anam works while Beyond Presence fails. That points to a missing/incorrect secret specific to the Bey plugin rather than a general LiveKit connectivity problem. What to check and fix (quick) 1. Confirm
MODEL_LIVEKIT_ENVS
exists and contains the LiveKit creds Bey expects. Anam likely uses the separate
LIVEKIT_*
vars while Beyond Presence requires
MODEL_LIVEKIT_ENVS
(JSON/string with the same creds). ◦ Example
.env
entry (single line JSON): MODEL_LIVEKIT_ENVS={"LIVEKIT_URL":"wss://test1-jl58sr5y.livekit.cloud","LIVEKIT_API_KEY":"API52yNX8hMFCRF","LIVEKIT_API_SECRET":"BaaP0KlLzyQohEO80inKnEB1fDyI66kB59IYGdHxxdAQ"} 1. Fix the LIVEKIT_URL value you posted — it contains Markdown-style link text and a mismatched host: ◦ Use the correct host and raw URL, e.g.: LIVEKIT_URL="wss://test1-jl58sr5y.livekit.cloud" • Ensure
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
are correct and match the secret. 1. Where to put
MODEL_LIVEKIT_ENVS
◦ Local/dev: add it to
/app/.env
(same place as your other LIVEKIT_* vars). ◦ Cloud/prod: add
MODEL_LIVEKIT_ENVS
to your secret manager (e.g., Google Secret Manager) or inject via your agent/infra secrets mechanism and ensure the service has access. 1. After adding/updating: ◦ Restart the agent process so it reloads env vars. ◦ Watch logs for the prior errors (
No LiveKit env found for model
and
Secret 'MODEL_LIVEKIT_ENVS' not found
) to confirm they disappear. If you want, tell me: • Are you running locally or in a cloud deployment (GCP / Kubernetes / LiveKit Cloud)? • Do you want the exact command to add
MODEL_LIVEKIT_ENVS
to Google Secret Manager or to update your agent secrets? I can provide the precise command/snippet for your environment.