I'm getting an error when trying to execute an age...
# ask-ai
l
I'm getting an error when trying to execute an agenttask. RuntimeError: trying to generate reply without an LLM model. in the examples on the livekit docs, i dont see any definition of adding an llm model. is there something im doing wrong?
t
Thanks for reaching out, Daniel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you're encountering the error
RuntimeError: trying to generate reply without an LLM model
. This usually happens when the
generate_reply()
method is called on an
AgentSession
that hasn't been set up with a Large Language Model (LLM) instance yet. No worries—we can get this sorted out together! To fix this, please make sure that an LLM is properly configured either in your
AgentSession
or directly in the
Agent
. Here are some friendly steps to help you configure an LLM: • Option A: Configure LLM in AgentSession
Copy code
session = AgentSession(
    llm=openai.LLM(model="gpt-4o-mini"),
    stt=deepgram.STT(),
    tts=cartesia.TTS(),
    vad=silero.VAD.load()
)
• Option B: Configure LLM in Agent
Copy code
class MyAgent(Agent):
    def __init__(self):
        super().__init__(
            instructions="Your instructions here",
            llm=openai.LLM(model="gpt-4o-mini")
        )
Also, a handy tip: you can use model string IDs directly, and they’ll be automatically turned into LLM instances for you:
Copy code
session = AgentSession(
    llm="openai/gpt-4.1-mini",
    # ... other components
)
If you try these and still run into trouble, it might be worth double-checking that the LLM is initialized properly and accessible. Please feel free to reach out if you want me to walk you through it or if you have any other questions—I’m here to help! Sources: tests/test_evals.py | Large language models (LLM) | LiveKit Docs