Skip to content
Try chatGet API key

LiveKit Agents

LiveKit Agents is a framework for real-time voice and video AI agents. Bayle serves as the LLM step through the OpenAI plugin.

Copies this page's setup instructions, to paste into your coding agent.
Show the prompt
Help me set this up to use Bayle AI, an OpenAI-compatible API. Full guide: https://docs.bayle.ai/guides/sdks/livekit-agents/

Goal: use a Bayle model as the LLM in my LiveKit Agents (https://docs.livekit.io/agents/) voice agent.

1. Install the OpenAI plugin if `python -c "from livekit.plugins import openai"` fails:
   pip install "livekit-agents[openai]"
2. Pick a model. Voice agents are latency-sensitive and LiveKit streams the reply, so prefer a fast, small one:
   curl -s "https://api.bayle.ai/models?type=text" | jq -r '.data[].id'
   Show me the list, let me choose, and use that id as MODEL_ID.
3. In my agent code, pass this LLM to the session. Use openai.LLM, which calls chat completions; openai.responses.LLM calls the Responses API, which Bayle does not serve. Leave my stt, tts and vad settings as they are, because Bayle provides the language model only:
   import os
   from livekit.agents import AgentSession
   from livekit.plugins import openai

   session = AgentSession(
       llm=openai.LLM(
           model="MODEL_ID",
           base_url="https://api.bayle.ai",
           api_key=os.environ["BAYLE_API_KEY"],
       ),
       # stt=..., tts=..., vad=... as usual
   )
4. Verify by constructing the LLM and sending it one short chat request (or running my agent in console mode if it supports it), and show me the result.

Rules:
1. The base URL is https://api.bayle.ai exactly as written. Append no path to it.
2. Read the key from the BAYLE_API_KEY environment variable. Never write the key itself into a file you create, a command, a commit or the chat. Where the tool keeps the key in its own settings screen, tell me where to paste it. If BAYLE_API_KEY is not set, stop and ask me to create a key at https://chat.bayle.ai/developers and export it.
3. Take model ids only from GET https://api.bayle.ai/models (no key needed). Never guess one.
4. Finish with one real test request, show me the result and list the files you changed.
Terminal window
pip install "livekit-agents[openai]"

See the official guide for the OpenAI-compatible setup.

Don't have a Bayle key yet?Get API key

Pass Bayle’s base URL and key to openai.LLM, and give it to your session:

import os
from livekit.agents import AgentSession
from livekit.plugins import openai
session = AgentSession(
llm=openai.LLM(
model="MODEL_ID",
base_url="https://api.bayle.ai",
api_key=os.environ["BAYLE_API_KEY"],
),
# stt=..., tts=..., vad=... as usual
)
  • Use openai.LLM, which calls chat completions. openai.responses.LLM calls the Responses API, which Bayle doesn’t serve.
  • Bayle provides the language model only. Speech-to-text and text-to-speech come from the other plugins you configure in the session.

Voice agents are latency-sensitive. LiveKit streams the reply, so pick a fast, small model; the first tokens arrive as soon as the model produces them.

Terminal window
curl -s "https://api.bayle.ai/models?type=text" | jq -r '.data[].id'