ERROR:livekit.agents:Error in _llm_inference_task ...
# ask-ai
n
ERRORlivekit.agentsError in _llm_inference_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 223, in _main_task await self._run() File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/llm.py", line 429, in _run raise APIStatusError( ...<5 lines>... ) from None livekit.agents._exceptions.APIStatusError: message='Error getting model definition', status_code=400, retryable=True, body=Error getting model definition The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/voice/generation.py", line 144, in _llm_inference_task async for chunk in llm_node: ...<47 lines>... ) File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/voice/agent.py", line 456, in llm_node async for chunk in stream: yield chunk File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 393, in anext raise exc # noqa: B904 ^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 195, in _traceable_main_task await self._main_task() File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 245, in _main_task raise APIConnectionError( f"failed to generate LLM completion after {self._conn_options.max_retry + 1} attempts", # noqa: E501 143934.342 ERROR livekit.agents Error in _llm_inference_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 223, in _main_task await self._run() File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/llm.py", line 429, in _run raise APIStatusError( ...<5 lines>... ) from None livekit.agents._exceptions.APIStatusError: message='Error getting model definition', status_code=400, retryable=True, body=Error getting model definition The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/voice/generation.py", line 144, in _llm_inference_task async for chunk in llm_node: ...<47 lines>... ) File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/voice/agent.py", line 456, in llm_node async for chunk in stream: yield chunk File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 393, in anext raise exc # noqa: B904 ^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 195, in _traceable_main_task await self._main_task() File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/llm/llm.py", line 245, in _main_task raise APIConnectionError( f"failed to generate LLM completion after {self._conn_options.max_retry + 1} attempts", # noqa: E501 ) from e INFOlivekit.agentsshutting down worker 143939.373 INFO livekit.agents shutting down worker {"id": "unregistered"} DEBUGlivekit.agentssession closed 143941.580 DEBUG livekit.agents session closed {"reason": "user_initiated", "error": null} DEBUGlivekit.agentsshutting down job task 143941.583 DEBUG livekit.agents shutting down job task {"reason": "", "user_initiated": false} DEBUGlivekit.agentsjob exiting 143941.584 DEBUG livekit.agents job exiting {"reason": "", "tid": 38189, "job_id": "mock-job-53ea8ce7937a", "room_id": "SRM_14aee2e5b988"} DEBUGlivekit.agentshttp_session(): closing the httpclient ctx 143941.585 DEBUG livekit.agents http_session(): closing the httpclient ctx INFOlivekit.agentsprocess exiting 143941.587 INFO livekit.agents process exiting {"reason": "", "pid": 38155, "inference": true}
✅ 1
t
Thanks for reaching out, Sajjad. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about the "Error getting model definition" 400 during LLM inference. Could you share these details so I can pinpoint the cause? • The exact model name and provider you configured for the agent (copy the value from your config). • The agent config file or the snippet where the model is set (sanitized of secrets). • Whether you recently changed the model, provider, or API key. • The environment (local, Docker, cloud) and LiveKit agents version (from pip freeze or package metadata). • Any additional API response body or provider logs (if available) beyond the traceback. If you prefer, paste the small config snippet and the command you run to start the agent — that will let me check likely misconfigurations (e.g., invalid model name, missing provider mapping, or malformed request). , with interactive elements
n
from http import server import logging from dotenv import load_dotenv from livekit import agents from livekit.agents import ( Agent, AgentServer, AgentSession, JobContext, RoomInputOptions, WorkerOptions, cli, ) from livekit.plugins import noise_cancellation, silero from livekit.plugins.turn_detector.multilingual import MultilingualModel load_dotenv(".env.local") AGENT_MODEL = "google/gemini-1.5-flash" class Assistant(Agent): def __init__(self) -> None: super().__init__( instructions="You are a helpful voice AI assistant.", ) server = AgentServer() @breezy-insurance-66772.rtc_session(agent_name="voice_assistant") async def entrypoint(ctx: JobContext): session = AgentSession( stt="deepgram/nova-3", llm="google/gemini-1.5-flash", tts="cartesia/sonic-2", vad=silero.VAD.load(), ) await session.start( agent=Assistant(), room=ctx.room, room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC(), ), ) await ctx.connect() if name == "__main__": logging.basicConfig(level=logging.INFO) agents.cli.run_app(server)
t
Thanks — I’m looking at the traceback and your code snippet. The error "Error getting model definition" 400 is caused by the LLM model identifier you configured:
google/gemini-1.5-flash
. Facts from the LiveKit model registry: •
google/gemini-1.5-flash
is not a supported model ID in LiveKit. • LiveKit resolves string model descriptors against its model registry; an unknown model ID causes the inference backend to return the 400 "Error getting model definition" error. What you can do now • Update the model reference to a supported Gemini model. For example: ◦ Change
AGENT_MODEL
and the
llm
session field to a supported ID such as
google/gemini-2.5-flash
(or another supported Gemini model). ◦ Example change in your code:
Copy code
AGENT_MODEL = "google/gemini-2.5-flash"
    ...
    session = AgentSession(
      stt="deepgram/nova-3",
      llm="google/gemini-2.5-flash",
      tts="cartesia/sonic-2",
      ...
    )
• Restart the agent after making the change. If you want, tell me: • Which Gemini model you want to use (I can confirm the exact supported ID), or • Paste your current sanitized config and I’ll suggest the exact edit. Sources: Google Gemini LLM | LiveKit Documentation | LiveKit Inference | LiveKit Documentation, with interactive elements
n
ERRORlivekitfailed to emit event agent_state_changed Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/rtc/event_emitter.py", line 58, in emit callback(*callback_args) ~~~~~~~~^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/agent.py", line 97, in _on_agent_state_changed delta = ev.created_at - last_eou_metrics.last_speaking_time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/pydantic/main.py", line 1042, in getattr 163003.810 ERROR livekit failed to emit event agent_state_changed Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/rtc/event_emitter.py", line 58, in emit callback(*callback_args) ~~~~~~~~^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/agent.py", line 97, in _on_agent_state_changed delta = ev.created_at - last_eou_metrics.last_speaking_time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/pydantic/main.py", line 1042, in getattr raise AttributeError(f'{type(self).name!r} object has no attribute {item!r}')
t
Thanks — I’m responding about the AttributeError in your
_on_agent_state_changed
handler where
last_eou_metrics.last_speaking_time
is accessed. Likely cause (based on the traceback) •
last_eou_metrics
is a Pydantic model (or possibly None) that does not have
last_speaking_time
defined, so attribute access raises AttributeError. To fix this I need one small code snippet and one detail: 1. Paste ~20–30 lines around your
_on_agent_state_changed
handler (show how
ev
and
last_eou_metrics
are created/assigned). 2. Share the model/structure for
last_eou_metrics
(or how it’s initialized) — just the class or the initialization site. Quick defensive fixes you can try immediately • Check existence before subtracting:
Copy code
if getattr(last_eou_metrics, "last_speaking_time", None) is None:
      # choose a default or skip delta calculation
      delta = None
  else:
      delta = ev.created_at - last_eou_metrics.last_speaking_time
• Or initialize
last_eou_metrics
with a default
last_speaking_time
when created so the attribute always exists. If you paste the handler + model/init, I’ll give an exact one-line patch and the preferred pattern (typing + default) to stop the exception. , with interactive elements
n
@session.on("agent_state_changed") def _on_agent_state_changed(ev: AgentStateChangedEvent): if ( ev.new_state == "speaking" and last_eou_metrics and session.current_speech and last_eou_metrics.speech_id == session.current_speech.id ): delta = ev.created_at - last_eou_metrics.last_speaking_time logger.info("Time to first audio frame: %sms", delta.total_seconds() * 1000)
t
Thanks — I’m responding about the AttributeError in your
_on_agent_state_changed
handler where
last_eou_metrics.last_speaking_time
is accessed. Cause •
last_eou_metrics
exists but does not have the attribute
last_speaking_time
, so Pydantic raises AttributeError when you try to read it. Quick fixes (pick one) 1) Defensive check before using the attribute
Copy code
if (
    ev.new_state == "speaking"
    and last_eou_metrics
    and session.current_speech
    and getattr(last_eou_metrics, "speech_id", None) == session.current_speech.id
    and getattr(last_eou_metrics, "last_speaking_time", None) is not None
):
    delta = ev.created_at - last_eou_metrics.last_speaking_time
    logger.info("Time to first audio frame: %sms", delta.total_seconds() * 1000)
2) Initialize
last_eou_metrics
with sensible defaults so the attribute always exists • Ensure the model or object used for
last_eou_metrics
includes
last_speaking_time: Optional[datetime] = None
(or a default datetime) when it’s created. 3) Use try/except if you prefer to log and continue on missing data
Copy code
try:
    delta = ev.created_at - last_eou_metrics.last_speaking_time
except AttributeError:
    logger.warning("Missing last_speaking_time on last_eou_metrics; skipping delta calculation")
else:
    logger.info("Time to first audio frame: %sms", delta.total_seconds() * 1000)
Next step I can help with • Paste the class/initialization of
last_eou_metrics
(or where it’s set). I’ll give the exact minimal change to add a typed default and the preferred pattern to avoid this across your code., with interactive elements
n
ERRORlivekit.agentsError in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... 164327.319 ERROR livekit.agents Error in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... )
t
You're seeing an APIStatusError in the interruption/inference pipeline — likely due to an invalid or misconfigured external inference model or creds. I’ll help pinpoint it; a couple quick checks and one small ask: What to check now • Confirm the LLM model ID you pass to AgentSession is a supported LiveKit model (unsupported IDs cause "Error getting model definition" 400). • Verify relevant API keys are set and correct in your environment (.env.local) for the provider of the LLM (e.g., Google/XAI/OpenAI). • Ensure the provider mapping matches the model (a Google model must be used with the Google/Realtime plugin or the correct adapter). Small info request so I can give an exact fix • Paste the AgentSession creation snippet (the lines where you set
stt
,
llm
,
tts
) — sanitized of secrets — and the value of
AGENT_MODEL
you used. • Tell me which provider key you set in .env.local (e.g., XAI_API_KEY, GOOGLE_API_KEY, OPENAI_API_KEY). If you want an immediate change: replace
google/gemini-1.5-flash
with a supported Gemini ID such as
google/gemini-2.5-flash
, ensure the matching provider API key is present, then restart the agent. Paste your session snippet and I’ll give the exact one-line edit if needed. Sources: Function tool definition | LiveKit Documentation, with interactive elements
n
from http import server import logging from venv import logger from dotenv import load_dotenv from livekit import agents from livekit.agents import ( Agent, AgentServer, AgentSession, JobContext, RoomInputOptions, WorkerOptions, cli, ) from livekit.plugins import noise_cancellation, silero from livekit.plugins.turn_detector.multilingual import MultilingualModel from livekit.agents import llm, stt, tts, inference from livekit.agents import AgentStateChangedEvent, MetricsCollectedEvent, metrics import time logger = logging.getLogger(name) load_dotenv(".env.local") class Assistant(Agent): def __init__(self) -> None: super().__init__( instructions="You are an upbeat, slightly sarcastic voice AI for tech support. " "Help the caller fix issues without rambling, and keep replies under 3 sentences." ) server = AgentServer() @breezy-insurance-66772.rtc_session(agent_name="voice_assistant") async def entrypoint(ctx: JobContext): session = AgentSession( stt=stt.FallbackAdapter( [ inference.STT.from_model_string("assemblyai/universal-streaming:en"), inference.STT.from_model_string("deepgram/nova-3"), ] ), llm=llm.FallbackAdapter( [ inference.LLM.from_model_string("google/gemini-2.5-flash"), inference.LLM.from_model_string("openai/gpt-4.1-mini"), ] ), tts=tts.FallbackAdapter( [ inference.TTS.from_model_string("cartesia/sonic-3:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc"), inference.TTS.from_model_string("inworld/inworld-tts-1"), ] ), vad=silero.VAD.load(), preemptive_generation=True, ) usage_collector = metrics.UsageCollector() last_eou_metrics: metrics.EOUMetrics | None = None @session.on("metrics_collected") def _on_metrics_collected(ev: MetricsCollectedEvent): nonlocal last_eou_metrics if ev.metrics.type == "eou_metrics": last_eou_metrics = ev.metrics metrics.log_metrics(ev.metrics) usage_collector.collect(ev.metrics) async def log_usage(): summary = usage_collector.get_summary() logger.info("Usage summary: %s", summary) ctx.add_shutdown_callback(log_usage) @session.on("agent_state_changed") def _on_agent_state_changed(ev: AgentStateChangedEvent): if ( ev.new_state == "speaking" and last_eou_metrics and session.current_speech # and last_eou_metrics.speech_id == session.current_speech.id and getattr(last_eou_metrics, "speech_id", None) == session.current_speech.id and getattr(last_eou_metrics, "last_speaking_time", None) is not None ): # delta = ev.created_at - last_eou_metrics.last_speaking_time # logger.info("Time to first audio frame: %sms", delta.total_seconds() * 1000) delta = ev.created_at - last_eou_metrics.last_speaking_time logger.info("Time to first audio frame: %sms", delta.total_seconds() * 1000) await session.start( agent=Assistant(), room=ctx.room, room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC(), ), ) await ctx.connect() if name == "__main__": logging.basicConfig(level=logging.INFO) agents.cli.run_app(server)
t
Thanks — I’m responding to the latest errors you shared (APIStatusError in the interruption pipeline plus the model-definition 400 earlier). Next steps to resolve these two root causes: 1) Model definition 400 • You are using supported model IDs in your posted session (e.g.,
google/gemini-2.5-flash
,
openai/gpt-4.1-mini
) — that fixes the earlier
google/gemini-1.5-flash
issue. Keep using the valid IDs you show. 2) APIStatusError in interruption/_main_task What to check now (do these in order): • Confirm provider API keys exist in your .env.local and are exported at runtime (e.g., `XAI_API_KEY`/`GOOGLE_API_KEY` for Gemini,
OPENAI_API_KEY
for OpenAI). Redact keys when sharing. • Inspect the full APIStatusError body (status code + message) from logs — that exact HTTP code identifies the cause (401 = auth, 429 = rate limit, 5xx = provider outage, 4xx = invalid request). • Ensure provider mapping matches model: Google Gemini model must be served by the Google/XAI provider adapter; OpenAI models must use OpenAI credentials. • If using FallbackAdapter, reproduce which adapter succeeded/failed by temporarily removing fallbacks and running each model singly to see which one triggers the error. Quick configuration tests you can run 1. Print env and model resolution before session start:
Copy code
import os
logger.info("XAI_API_KEY set: %s", bool(os.getenv("XAI_API_KEY")))
logger.info("OPENAI_API_KEY set: %s", bool(os.getenv("OPENAI_API_KEY")))
logger.info("LLM fallback list: %s", session.llm.adapters if hasattr(session, "llm") else "n/a")
1. Run with a single LLM (no fallback): • Set
llm=inference.LLM.from_model_string("google/gemini-2.5-flash")
and restart. If error disappears, add back the fallback adapters one-by-one. 1. Add error handling around send_task to capture full APIStatusError details:
Copy code
try:
    # code that triggers send_task / generation
except APIStatusError as e:
    logger.error("LLM APIStatusError: status=%s body=%s", getattr(e, "status_code", None), getattr(e, "body", None))
    raise
If you share these two items I’ll give the exact next edit: • The full APIStatusError body (status code + body text) from your logs. • Which single-model test failed (if you ran the single-model run from step 2). I can then tell you whether it’s an auth issue, rate limiting, unsupported model usage, or a provider error and give the minimal code/config fix. , with interactive elements
n
can you tell me which gemini model are supported fro llm
t
Thanks — you’re asking which Google Gemini model IDs are supported for LLMs in LiveKit. Use one of these valid IDs: •
google/gemini-2.5-flash
•
google/gemini-2.5-flash-lite
•
google/gemini-2.5-pro
•
google/gemini-3-flash-preview
•
google/gemini-3.1-flash-lite-preview
•
google/gemini-3.1-pro-preview
Notes: • Do not use retired/unsupported IDs (e.g., any
1.5
names or
google/gemini-2.0-flash
). • Configure the LLM in your session with one of the IDs above (e.g.,
llm=inference.LLM.from_model_string("google/gemini-2.5-flash")
) and restart the agent. If you want, tell me which Gemini model you prefer and I’ll confirm the exact code line to use. Sources: Google Gemini LLM | LiveKit Documentation, with interactive elements
n
? for shortcuts ERRORlivekit.agentsError in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... 170022.542 ERROR livekit.agents Error in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... ) interrupt is giveing errot
t
Thanks — you’re seeing an APIStatusError coming from the interruption/inference pipeline when the agent tries to send a generation task. That usually means an external inference call failed (auth, rate limit, unsupported model, or provider-side error). Let’s pinpoint it. Please provide: • The full APIStatusError details from your logs (status code and body text). • Which LLM in the FallbackAdapter failed when you reproduced with single-model runs (did the error appear with Gemini or OpenAI?). • The relevant env vars from .env.local (just keys presence, e.g., XAI_API_KEY set: True/False, OPENAI_API_KEY set: True/False). While you gather that, try these quick checks: • Run with a single LLM (no fallback), e.g.: ◦ llm=inference.LLM.from_model_string("google/gemini-2.5-flash") ◦ Restart and see if error persists. • Confirm API keys are visible to the process: ◦ logger.info("XAI_API_KEY set: %s", bool(os.getenv("XAI_API_KEY"))) etc. • Capture richer error info around send_task:
Copy code
except APIStatusError as e:
      logger.error("LLM APIStatusError: status=%s body=%s", getattr(e,"status_code",None), getattr(e,"body",None))
      raise
Send the three items above (status/body, which single-model failed, API key presence) and I’ll tell you the exact fix (auth, model change, or adapter mapping). , with interactive elements
n
ERRORlivekit.agentsError in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... 170444.761 ERROR livekit.agents Error in _main_task Traceback (most recent call last): File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/utils/log.py", line 17, in async_fn_logs return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 479, in _main_task return await self._run() ^^^^^^^^^^^^^^^^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 1094, in _run task.result() ~~~~~~~~~~~^^ File "/home/athar/python_projects/WORKSHOP_DEMO/livekit-voice-agent/.venv/lib/python3.13/site-packages/livekit/agents/inference/interruption.py", line 947, in send_task raise APIStatusError( ...<4 lines>... ) how to trace
t
You're asking how to trace the recurring APIStatusError coming from the interruption/inference pipeline. I’ll walk you through quick, practical steps to capture the full error and pinpoint the root cause. Enable detailed logging 1. Turn on debug logging globally before starting the agent:
Copy code
import logging
logging.basicConfig(level=logging.DEBUG)
1. Also ensure your process shows stdout/stderr (no silent redirect) so debug logs appear. Capture full APIStatusError details 1. Wrap the inference/send task to log status and body:
Copy code
from livekit.agents._exceptions import APIStatusError

try:
    # code that triggers generation/send_task
except APIStatusError as e:
    logger.error("LLM APIStatusError: status=%s body=%s", getattr(e, "status_code", None), getattr(e, "body", None))
    raise
1. Search your logs for those lines — the HTTP status code and response body tell you if it’s auth (401), rate limit (429), invalid model (400), or server error (5xx). Narrow which adapter/model fails 1. Temporarily remove FallbackAdapter and run each model individually: ◦ Test Gemini only: llm=inference.LLM.from_model_string("google/gemini-2.5-flash") • Test OpenAI only: llm=inference.LLM.from_model_string("openai/gpt-4.1-mini") 1. The model that reproduces the error is the failing provider. Verify credentials & mapping • Confirm presence (True/False) of relevant env vars in runtime:
Copy code
import os
logger.info("XAI_API_KEY set: %s", bool(os.getenv("XAI_API_KEY")))
logger.info("OPENAI_API_KEY set: %s", bool(os.getenv("OPENAI_API_KEY")))
• Ensure model - provider mapping is correct (Google models via XAI/Google adapter, OpenAI models via OPENAI_API_KEY). Instrument interruption/send_task for trace 1. Add timing and context logs around interruption code to know which request caused the error:
Copy code
logger.debug("Sending interruption task: model=%s speech_id=%s", model_id, session.current_speech.id if session.current_speech else None)
1. Log task result or exception immediately so you can correlate with metrics/events. Use LiveKit observability & console • Check Agent Console/session metrics for request failures and rate limits. • Inspect InterruptionMetrics and usage logs to correlate timing of the APIStatusError. If you still see the error, please paste: • The exact APIStatusError log lines you get after adding the logging (status code and body). • Which single-model test reproduced the error (Gemini or OpenAI). With those I’ll tell you whether it’s auth, rate limiting, unsupported model, or provider-side failure and the minimal fix. Sources: Large language models (LLM) overview | LiveKit Documentation | Google Gemini LLM | LiveKit Documentation | Gemini Live API plugin | LiveKit Documentation | Troubleshooting 401 Unauthorized and Token Errors | LiveKit | Solving unwanted interruptions with Adaptive Interruption Handling | LiveKi..., with interactive elements