5-10-16 01:28:20,807 - WARNING livekit.agents - fa...
# ask-ai
a
2025-10-16 012820,807 - WARNING livekit.agents - failed to synthesize speech, retrying in 0.1s {"tts": "livekit.agents.inference.tts.TTS", "attempt": 1, "streamed": true} Traceback (most recent call last): File ".../livekit/agents/tts/tts.py", line 383, in _main_task await self._run(output_emitter) File ".../livekit/agents/inference/tts.py", line 471, in _run raise APIStatusError( livekit.agents._exceptions.APIStatusError: Invalid response status (status_code=429, request_id=None, body=None, retryable=False) 2025-10-16 012820,808 - ERROR livekit.agents - AgentSession is closing due to unrecoverable error Traceback (most recent call last): File ".../livekit/agents/stt/stt.py", line 289, in _main_task return await self._run() File ".../livekit/agents/inference/stt.py", line 416, in _run ws = await self._connect_ws() File ".../livekit/agents/inference/stt.py", line 469, in _connect_ws ws = await asyncio.wait_for(...) aiohttp.client_exceptions.WSServerHandshakeError: 429, message='Invalid response status', url='wss://agent-gateway.livekit.cloud/v1/stt' 2025-10-16 012820,817 - DEBUG livekit.agents - session closed {"reason": "error", "error": "type='stt_error' timestamp=... label='livekit.agents.inference.stt.STT' error=WSServerHandshakeError(...) recoverable=False"} Issue Summary: My agent keeps failing with 429 Too Many Requests errors on both STT and TTS. The logs show repeated handshake failures at wss://agent-gateway.livekit.cloud/v1/stt and occasional TTS retries failing immediately. Even when only one agent is active, LiveKit’s backend seems to register multiple concurrent inference sockets. --- Error Snippet (sanitized): livekit.agents._exceptions.APIStatusError: Invalid response status (status_code=429, request_id=None, retryable=False) aiohttp.client_exceptions.WSServerHandshakeError: 429, message='Invalid response status', url='wss://agent-gateway.livekit.cloud/v1/stt' livekit.agents - session closed {"reason": "error", "error": "type='stt_error' ... recoverable=False"} --- What I’ve Already Tried: Restarted PC and all Python environments. Deleted .venv, reinstalled dependencies, recreated uv environment. Verified I have no active rooms (cleanup_sessions.py shows 0 rooms). Ran the default LiveKit test agent — still fails with the same 429. Ensured no local concurrency or other sessions running. Confirmed tokens are valid and generated fresh. Tried switching STT models (AssemblyAI → LiveKit default) — no difference.
t
Thanks for reaching out, RAGE. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand that encountering 429 Too Many Requests errors for STT and TTS in LiveKit agents can be frustrating. These errors usually happen when the default quota limits are exceeded. Don’t worry, here are some friendly steps that can help you resolve this: • Scale Infrastructure: Consider running multiple agent servers to spread out the load, and you might want to dedicate some servers specifically for agent workloads. • Implement Error Recovery: It’s a good idea to use error callbacks in your agents to handle 429 errors smoothly. For example, TTS and LLM errors can be marked as recoverable like this:
Copy code
@session.on("error")
def on_error(ev: ErrorEvent):
    if ev.error.recoverable:
        return

    if isinstance(ev.source, (tts.TTS, llm.LLM)):
        ev.error.recoverable = True
        return
• Monitor and Optimize: Make sure you have enough workers available and try deploying agents in regions closer to AI service providers to help reduce latency. • Request Quota Increases: If you find that your workload often goes beyond the default limits (5 active connections for STT and TTS), you can easily request a quota increase through LiveKit Cloud. Please feel free to reach out if you’d like any help with these steps or if there’s anything else I can assist you with. I’m here to support you! Sources: livekit-agents/livekit/agents/inference/tts.py | livekit/livekit_agent_dispatch.twirp.go | Quotas and limits | LiveKit Docs | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | Troubleshooting & Common Issues | livekit/livekit_composite | DeepWiki
a
But what limits did I surpass? If I send a screenshot of usage would you be able to help me out?
t
I’m here to help! The default limits for LiveKit Cloud are 5 active connections each for STT and TTS. If you could share a screenshot of your usage, I’d be happy to take a look and guide you through the next steps together.
a
Screenshot_20251016_020224_Chrome.jpg
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
a
Can you look over the screenshot and let me know if I surpassed any limit possibly the free inference. If so how would I circumvent this? Should I use a plugin?