white-telephone-81843
12/19/2025, 7:21 AMtall-airline-16756
12/19/2025, 7:21 AMtall-airline-16756
12/19/2025, 7:22 AMfrom livekit.plugins import xai
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=xai.realtime.RealtimeModel(
voice="ara" # optional: "ara", "sabina", "jose", "daniel", etc.
),
)
2) Set the Grok (xAI) API key in env
XAI_API_KEY=your_grok_api_key_here
Load it with your existing dotenv or env loader.
3) Install the plugin (if not already)
uv add "livekit-agents[xai]~=1.3"
Notes:
• Remove the with_azure(...) call and the Azure-specific env vars (AZURE_OPENAI_*).
• Authentication uses XAI_API_KEY, not Azure keys.
• If you want, I can show how to pass additional realtime options (turn detection, TTS settings, or custom voice). Which would you like next? Sources: xAI Grok Voice Agent API plugin | LiveKit docs | xAI and LiveKit | LiveKit docstall-airline-16756
12/19/2025, 7:29 AMxai extra the way you attempted to add it.
Quick checklist and steps to resolve:
1. Confirm your environment:
• Which Python package manager are you using (`uv`/pdm/poetry/pip`)?
• Run and share: uv show livekit-agents (or pip show livekit-agents) to confirm the installed version.
1. Install the xAI plugin correctly:
• If you’re using uv, run:
uv add "livekit-agents[xai]~=1.3"
• If you use `pip`:
pip install "livekit-agents[xai]~=1.3"
This will pull the xai extra that provides the livekit.plugins.xai module.
1. If the extra still isn’t available:
• Upgrade livekit-agents to the latest 1.3.x that includes the extra:
uv add "livekit-agents~=1.3.5"
# or
pip install --upgrade "livekit-agents~=1.3"
• Then re-run the uv add "livekit-agents[xai]~=1.3" install.
1. Env & code reminders:
• Ensure XAI_API_KEY is set in your environment or .env.
• Replace openai.realtime.RealtimeModel.with_azure(...) with xai.realtime.RealtimeModel(...) in code.
If you run the install command and still see the warning, paste the output of uv show livekit-agents (or pip show livekit-agents) and I’ll tell you the exact next step. Which package manager did you run uv sync with?
Sources: xAI and LiveKit | LiveKit docs | xAI LLM plugin guide | LiveKit docstall-airline-16756
12/19/2025, 7:31 AMuv add "livekit-agents[openai]~=1.3"
# or with pip
pip install "livekit-agents[openai]~=1.3"
2) Set your Grok API key
export XAI_API_KEY=your_grok_api_key_here
# or add to .env and load it with dotenv
3) Update your code to use the OpenAI plugin’s xAI helper:
from livekit.plugins import openai
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=openai.LLM.with_x_ai(
model="grok-4-1-fast-non-reasoning", # or other Grok model
api_key=os.getenv("XAI_API_KEY"),
),
)
Notes:
• Keep your current livekit-agents 1.3.5; the xai extra isn’t exposed there, but the openai extra supports with_x_ai() for Grok.
• If you prefer using livekit.plugins.xai directly, upgrade to a livekit-agents release that includes the xai extra and then install livekit-agents[xai]~=1.3.
Want me to provide the exact upgrade command for switching to the xai extra?
Sources: xAI LLM plugin guide | LiveKit docswhite-telephone-81843
12/19/2025, 7:37 AMtall-airline-16756
12/19/2025, 7:38 AMopenai.LLM.with_x_ai(...) can be correct only if:
◦ You installed the OpenAI plugin extra (livekit-agents[openai]) for your livekit-agents version.
◦ You set XAI_API_KEY with your Grok key.
◦ You use a supported Grok model name (e.g., grok-2-public or grok-beta), not an unsupported model string.
Correct minimal example (OpenAI plugin path)
from livekit.plugins import openai
from livekit.agents import AgentSession
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=openai.LLM.with_x_ai(
model="grok-2-public",
api_key=os.getenv("XAI_API_KEY"),
),
)
If you intend real-time voice (low-latency speech), use the xai realtime plugin instead:
from livekit.plugins import xai
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=xai.realtime.RealtimeModel(
model="grok-beta",
voice="ara",
),
)
That requires livekit-agents[xai] and XAI_API_KEY set.
Troubleshooting why the phone call gets no answer Please confirm or check each item below and tell me the results so I can narrow this quickly:
1. Agent process status
• Is your agent running and started in dev mode (e.g., python agent.py dev)? Check the agent logs for connection/registration messages.
1. Dispatch rule & agent name
• Does your dispatch rule in Telephony point to the exact agent name your code registers? (Agent name must match the dispatch rule.)
1. Telephony configuration
• Is the phone number associated with the dispatch rule that routes to your agent? Verify in LiveKit Cloud → Telephony → Configuration.
1. Plugin & API key
• Which package did you install? Share output of uv show livekit-agents or pip show livekit-agents.
• Confirm XAI_API_KEY is set and accessible to the running process.
1. Model choice
• Which model did you specify? Use grok-2-public or grok-beta for supported flows. If using realtime voice, use xai.realtime.RealtimeModel.
1. Logs/errors when calling
• Do you see any errors in agent logs when the call arrives (webhook/telephony logs)? Paste any error lines you see.
Next step
• Tell me: which plugin path you prefer (OpenAI plugin with with_x_ai() or xai realtime), the livekit-agents version you have, and paste any relevant log lines. I’ll provide the exact code snippet and the next fix based on that. Sources: xAI Grok Voice Agent API plugin | LiveKit docs | xAI LLM plugin guide | LiveKit docs | SIP troubleshooting guide | LiveKit docs | Simple Call Answering Agent | LiveKit docswhite-telephone-81843
12/19/2025, 7:47 AMtall-airline-16756
12/19/2025, 7:48 AMXAI_API_KEY is set.
Next, let’s narrow down why the call isn’t answered. Please provide these quick checks and answers:
1. Which plugin path are you using in code?
◦ openai.LLM.with_x_ai(...) or xai.realtime.RealtimeModel(...)?
1. livekit-agents install & version (paste output):
◦ Run uv show livekit-agents or pip show livekit-agents.
1. How are you running the agent?
◦ Command you run (e.g., python agent.py dev, uv run, etc.).
1. Agent name vs dispatch rule:
◦ Does your agent register a name? Share the agent_name in your code or the decorator.
◦ Confirm the Telephony dispatch rule points to that exact name.
1. Model string you set in code (exact value).
2. Any relevant logs when a call comes in (agent logs, telephony logs, or errors). Paste the most recent lines.
With those details I’ll give the exact corrected snippet and the likely fix (routing, plugin mismatch, or runtime/env issue).white-telephone-81843
12/19/2025, 7:49 AMtall-airline-16756
12/19/2025, 7:49 AMgrok-4-1-fast-non-reasoning is not a documented Grok model for LiveKit. Use a supported model name.
• If you’re using the OpenAI plugin path, use this minimal, correct form:
from livekit.plugins import openai
from livekit.agents import AgentSession
import os
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=openai.LLM.with_x_ai(
model="grok-2-public", # use a supported model
api_key=os.getenv("XAI_API_KEY"), # ensure this is set
),
)
• If you want realtime voice (low-latency), instead use the xai realtime plugin:
from livekit.plugins import xai
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
llm=xai.realtime.RealtimeModel(
model="grok-beta",
voice="ara",
),
)
2) Telephony routing & runtime checks (most common cause of “no answer”) Please confirm these quickly:
• livekit-agents package/version: run uv show livekit-agents or pip show livekit-agents and paste output.
• Which plugin you installed: livekit-agents[openai] or livekit-agents[xai]?
• How you run the agent (exact command — e.g., python agent.py dev).
• Agent registration name / decorator (does your agent set agent_name?), and that the Telephony dispatch rule points to that exact name.
• Any agent logs when a call arrives (paste the last 10–20 lines).
Give me those answers and I’ll provide the exact code you should run and the single next step to fix the no-answer behavior.