inference.LLM crashes on openai@6.36.0+ due to empty-string apiKey at construction

Versions

  • @livekit/agents: 1.3.2
  • openai (transitive): 6.36.0
  • Node 22

Repro

import { inference } from ‘@livekit/agents’;
new inference.LLM({ model: ‘openai/gpt-4.1-mini’ }); // throws

No OPENAI_API_KEY set — auth is expected to go through the LiveKit inference gateway at request time.

Stack

OpenAIError: Missing credentials. Please pass an apiKey, workloadIdentity,
adminAPIKey, or set the OPENAI_API_KEY or OPENAI_ADMIN_KEY environment variable.
at new OpenAI (openai@6.36.0/client.js:143:19)
at new LLM (@livekit/agents@1.3.2/dist/inference/llm.cjs:111:19)

Expected

inference.LLM should construct without an OpenAI API key, since the inference path authenticates through the LiveKit
gateway, not OpenAI.

Impact

Fresh installs of @livekit/agents resolving openai@6.36.0+ crash at job entry for any agent using
inference.{LLM,STT,TTS}.

Currently we unblocked ourselves from this error by pinning to openai@6.15.0, but this is not really a sustainable solution longterm.

I am experiencing the same issue with the LiveKit official node.js starter template

This is fixed here and is going out in next release:

https://github.com/livekit/agents-js/pull/1411