I am hitting rate limits despite being the only pe...
# ask-ai
s
I am hitting rate limits despite being the only person using my application. I am hitting STT and TTS limits, despite being the only person calling. Why is this?
t
Thanks for reaching out, Gabriel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're hitting STT/TTS limits because limits are based on concurrent model usage, not number of human users. A few common causes and quick checks: • Concurrency limits: Build plan allows 5 active STT and 5 active TTS connections. Multiple open sockets, parallel audio segments, or aggressive retries can exceed that even for one user. • LLM bottlenecks: LLM request/token limits can slow your pipeline and cause retries/backpressure that increase STT/TTS concurrency. • Cold starts/reconnections: Agents can spawn bursts of connections on start or reconnects. • Multiple sessions/tracks: One user can still create multiple room joins, audio tracks, or reconnect attempts — each active stream counts. Actions you can take now • Check your project dashboard (Settings → Project) to view STT/TTS concurrency. • Log STT/TTS metrics (
STTMetrics
and
TTSMetrics
) to see concurrent connections, durations, and retry patterns. • Add exponential backoff on retries and avoid creating duplicate agent instances or parallel streams. If you want, tell me: • Your LiveKit plan (Build, Scale, etc.) • Whether you use LiveKit Inference or third-party plugins • Typical call duration, frequency, and how many audio streams/tracks are active With those I can point to specific diagnostics and recommend whether optimizing usage or requesting a limit increase is the right next step. Sources: Quotas and limits | LiveKit docs | Observability data hooks | LiveKit docs | Introducing LiveKit Inference: A unified model interface for voice AI
s
My LiveKit plan is Build. Call duration is < 1 minute, usually every 10 minutes while I test
t
Thanks — that helps. You're on the Build plan, so the key point: concurrency limits (not user count) are what cause STT/TTS rate errors. Quick summary tailored to your tests: • Build plan allows 5 active STT and 5 active TTS connections. Short calls every 10 minutes can still hit that if your app opens multiple connections, reconnects quickly, or processes parallel audio tracks. • Cold starts/reconnections or aggressive retry logic can create bursts that exceed the 5-connection limit even for <1 minute calls. • LLM throttling can create backpressure that increases STT/TTS concurrency (retries/queued requests). Immediate steps to try • Check the Project tab in the LiveKit Cloud dashboard to see concurrent STT/TTS usage during a test. • Add exponential backoff to retries and avoid creating duplicate agent instances or simultaneous audio tracks. • Consolidate streams so each session uses a single STT/TTS connection where possible. • Instrument
STTMetrics
and
TTSMetrics
to watch
streamed
,
audio_duration
, and
characters_count
. A couple quick questions so I can give concrete next steps: • Are you using LiveKit Inference or third‑party STT/TTS plugins? • When you run a test, do you see multiple active connections in the dashboard or just one? Answer those and I’ll recommend targeted diagnostics or whether a plan increase is appropriate.
s
I’m using LiveKit Inference
I only see one active connection
t
Thanks — since you’re on the Build plan and using LiveKit Inference, the root cause is concurrency limits (not user count). Quick, focused checklist and next steps: Why this happens • Build plan allows 5 active STT and 5 active TTS connections. LiveKit Inference counts concurrent audio streams/connections, so reconnects, parallel segments, or multiple published tracks can exhaust those slots even for a single tester. • Cold starts or agent reconnections can briefly open multiple connections. • LLM backpressure (requests throttled) can cause retries/queueing that increase concurrent STT/TTS usage. What to try now • Run a test while watching the Project tab (Settings → Project) to observe STT/TTS concurrency during the test. • Ensure each session uses a single STT and single TTS connection (no duplicate agent instances or extra audio tracks). • Add exponential backoff to any retry logic and avoid rapid reconnects. • Instrument
STTMetrics
and
TTSMetrics
to track
streamed
,
audio_duration
, and
characters_count
during your tests. If you still hit limits after those changes, tell me: • Whether you see multiple active connections in the dashboard during a single test • Approximate number of audio tracks published per session I’ll recommend targeted diagnostics or next steps (optimize usage vs request increased concurrency). Would you like instructions for how to view the concurrency metrics in the dashboard?
Thanks — since you’re on the Build plan, concurrency (not user count) is the cause. A few targeted checks to find the culprit: 1. Inspect agent logs for rapid STT/TTS starts or retries during a test (reconnects or retry loops can open extra concurrent requests). 2. Confirm your client publishes only a single audio track and that your agent isn’t creating duplicate sessions or agent instances. 3. Instrument
STTMetrics
and
TTSMetrics
during a test and watch
streamed
,
audio_duration
, and timestamps to see overlapping requests. 4. Run a test while watching the Project → Project tab in the Cloud dashboard to see concurrency spikes in real time. If you still hit limits while seeing only one visible connection, paste: • a short snippet of your agent logs around a test run (STT/TTS start/retry events), • the number of published audio tracks per session, and I’ll point to exactly which events are consuming concurrency and recommend fixes (backoff, single-connection flow, or whether a plan increase is needed). Sources: Quotas and limits | LiveKit docs | Agents (Python) | livekit/livekit_composite | DeepWiki
s
I cannot even get my agent session to start.
t
Sorry you're blocked — let's troubleshoot the agent startup. Please share the following so I can pinpoint the failure: • Exact error message you see (copy/paste). • A short agent log snippet from the moment you try to start the session (include any STT/TTS/Inference errors or stack traces). • How you authenticate LiveKit Inference (are you using the project API key or a different key?). • Whether the dashboard shows any STT/TTS concurrency or failed requests when you attempt startup. • Number of audio tracks the client publishes and whether the client attempts immediate reconnects. • Any recent code changes to agent initialization or retry logic. While you gather that, try this quick check: • Restart the agent process and run a single clean test with only one published audio track and no retry/backoff logic to see if the session starts. Send the error/logs and I’ll point to the likely cause and exact next steps.
s
Copy code
[14:14:40.392] ERROR (44388): Unhandled error. ({
  type: 'error',
  error: APIConnectionError: Error connecting to LiveKit WebSocket
      at WebSocket.onError ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/inference/utils.ts:48:16)
      at Object.onceWrapper (node:events:633:26)
      at WebSocket.emit (node:events:518:28)
      at emitErrorAndClose ([REDACTED]/node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/websocket.js:1041:13)
      at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
    body: null,
    retryable: true
  },
  source: STT {
    _events: [Object: null prototype] {
      metrics_collected: [Function (anonymous)],
      error: [Function (anonymous)]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    opts: {
      model: 'assemblyai/universal-streaming',
      language: 'en',
      encoding: 'pcm_s16le',
      sampleRate: 16000,
      baseURL: 'wss://agent-gateway.livekit.cloud/v1',
      apiKey: 'REDACTED',
      apiSecret: 'REDACTED',
      modelOptions: {}
    },
    streams: Set(1) { [SpeechStream] },
    [Symbol(shapeMode)]: false,
    [Symbol(kCapture)]: false
  },
  createdAt: 1765224880389
})
    jobID: "AJ_CtpS8V72KxHt"
    err: {
      "type": "Error",
      "message": "Unhandled error. ({\n  type: 'error',\n  error: APIConnectionError: Error connecting to LiveKit WebSocket\n      at WebSocket.onError ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/inference/utils.ts:48:16)\n      at Object.onceWrapper (node:events:633:26)\n      at WebSocket.emit (node:events:518:28)\n      at emitErrorAndClose ([REDACTED]/node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/websocket.js:1041:13)\n      at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {\n    body: null,\n    retryable: true\n  },\n  source: STT {\n    _events: [Object: null prototype] {\n      metrics_collected: [Function (anonymous)],\n      error: [Function (anonymous)]\n    },\n    _eventsCount: 2,\n    _maxListeners: undefined,\n    opts: {\n      model: 'assemblyai/universal-streaming',\n      language: 'en',\n      encoding: 'pcm_s16le',\n      sampleRate: 16000,\n      baseURL: 'wss://agent-gateway.livekit.cloud/v1',\n      apiKey: 'REDACTED',\n      apiSecret: 'REDACTED',\n      modelOptions: {}\n    },\n    streams: Set(1) { [SpeechStream] },\n    [Symbol(shapeMode)]: false,\n    [Symbol(kCapture)]: false\n  },\n  createdAt: 1765224880389\n})",
      "stack":
          Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
            type: 'error',
            error: APIConnectionError: Error connecting to LiveKit WebSocket
                at WebSocket.onError ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/inference/utils.ts:48:16)
                at Object.onceWrapper (node:events:633:26)
                at WebSocket.emit (node:events:518:28)
                at emitErrorAndClose ([REDACTED]/node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/websocket.js:1041:13)
                at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
              body: null,
              retryable: true
            },
            source: STT {
              _events: [Object: null prototype] {
                metrics_collected: [Function (anonymous)],
                error: [Function (anonymous)]
              },
              _eventsCount: 2,
              _maxListeners: undefined,
              opts: {
                model: 'assemblyai/universal-streaming',
                language: 'en',
                encoding: 'pcm_s16le',
                sampleRate: 16000,
                baseURL: 'wss://agent-gateway.livekit.cloud/v1',
                apiKey: 'REDACTED',
                apiSecret: 'REDACTED',
                modelOptions: {}
              },
              streams: Set(1) { [SpeechStream] },
              [Symbol(shapeMode)]: false,
              [Symbol(kCapture)]: false
            },
            createdAt: 1765224880389
          })
              at AgentSession.emit (node:events:507:17)
              at AgentSession.emit ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/voice/agent_session.ts:205:18)
              at AgentActivity.onError ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/voice/agent_activity.ts:520:25)
              at STT.<anonymous> ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/voice/agent_activity.ts:276:43)
              at STT.emit (node:events:518:28)
              at SpeechStream.emitError ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/stt/stt.ts:231:15)
              at SpeechStream.mainTask ([REDACTED]/node_modules/.pnpm/@livekit+agents@1.0.24_@livekit+rtc-node@0.13.21_zod@3.25.76/node_modules/@livekit/agents/src/stt/stt.ts:205:18)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      "code": "ERR_UNHANDLED_ERROR",
      "context": {
        "type": "error",
        "error": {
          "body": null,
          "retryable": true,
          "name": "APIConnectionError"
        },
        "source": {
          "_events": {},
          "_eventsCount": 2,
          "opts": {
            "model": "assemblyai/universal-streaming",
            "language": "en",
            "encoding": "pcm_s16le",
            "sampleRate": 16000,
            "baseURL": "wss://agent-gateway.livekit.cloud/v1",
            "apiKey": "REDACTED",
            "apiSecret": "REDACTED",
            "modelOptions": {}
          },
          "streams": {}
        },
        "createdAt": 1765224880389
      }
    }
t
Thanks — I see the APIConnectionError when the STT component attempts to open a WebSocket to
wss://agent-gateway.livekit.cloud/v1
. That prevents the agent session from starting. Let’s troubleshoot step-by-step. Please confirm or try each of the following: 1. API credentials • Confirm the API key and secret used for LiveKit Inference are correct and not expired. • Are you using the project API key/secret (not a different or limited key)? 1. Network / firewall • Can your host reach
*.livekit.cloud
on TCP port 443? Corporate networks or firewalls often block WebSocket traffic. • From the agent host run a quick check (curl or openssl) to validate TLS to the gateway and DNS resolution. 1. SDK / agent version • You’re running @livekit/agents v1.0.24. Please confirm you’re on Node SDK v1.0.7+ (latest Agents SDK recommended). If not, try upgrading. 1. Retryable error behavior • The error shows
retryable: true
. If your agent immediately spawns many retries, that can cause transient failures. Add/examine exponential backoff for STT connection attempts while we diagnose connectivity. 1. Dashboard & metrics • While attempting startup, does the Project dashboard show any attempted STT/TTS connections or failed requests? • Any STTMetrics/TTSMetrics entries at that timestamp? Please paste these items if you can: • The exact API key type you’re using (project key or other). • Output of a connectivity test (e.g.,
curl -Iv https://agent-gateway.livekit.cloud/v1
or
openssl s_client -connect agent-gateway.livekit.cloud:443
) run from the agent host. • Any additional agent logs around the same timestamp showing connection attempts or retries. If you confirm credentials and network access look good, paste the connectivity output and a short log snippet of the first connection attempt — I’ll point to the precise next steps (auth mismatch vs network vs SDK issue).