# 401 error on python agent.py dev - wss://.livekit.cloud/agent

**URL:** <https://community.livekit.io/t/401-error-on-python-agent-py-dev-wss-livekit-cloud-agent/337>\
**Category:** Agents\
**Tags:** agent-development, python\
**Created:** [February 20, 2026, 9:01pm UTC](https://community.livekit.io/t/401-error-on-python-agent-py-dev-wss-livekit-cloud-agent/337 "2026-02-20T21:01:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smartforwork](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/smartforwork/32/413_2.png) [@Smartforwork](https://community.livekit.io/u/Smartforwork)\
**Post date:** [February 20, 2026, 9:01pm UTC](https://community.livekit.io/t/401-error-on-python-agent-py-dev-wss-livekit-cloud-agent/337/1 "2026-02-20T21:01:15Z")

</div>

Getting persistent 401 errors when running `python agent.py dev` with livekit-agents 1.4.2.

Same API key works fine for RoomService API calls (200 OK). Agent runs perfectly in `console` mode.

Error: `WSServerHandshakeError: 401, message='Invalid response status', url='wss://reyns-1lk896kt.livekit.cloud/agent'`

Stack: Python 3.12, livekit-agents 1.4.2, LiveKit Cloud (Build plan). Any idea why the /agent endpoint rejects my key?

---

<div class="post-metadata">

**Author:** ![CWilson](https://sea1.discourse-cdn.com/flex001/user_avatar/community.livekit.io/cwilson/32/135_2.png) [@CWilson](https://community.livekit.io/u/CWilson)\
**Post date:** [February 20, 2026, 9:14pm UTC](https://community.livekit.io/t/401-error-on-python-agent-py-dev-wss-livekit-cloud-agent/337/2 "2026-02-20T21:14:47Z")

</div>

That usually indicates your system clock is not correct or you do not have proper env variables set.
