Can I integrate livekit with langgraph?
# ask-ai
p
Can I integrate livekit with langgraph?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes, you can definitely integrate LiveKit with LangGraph using the
livekit-plugins-langchain
package. This makes it super easy to use LangGraph workflows as large language models (LLMs) within LiveKit's AI agents framework, especially if you're working on voice AI applications. Here’s a quick way to get started: • First, install the plugin with
pip install "livekit-plugins-langchain~=1.1"
. • Then, define and compile your LangGraph workflow. • Finally, plug that workflow into a LiveKit
AgentSession
using the
LLMAdapter
. If you want a hands-on example, check out the LiveKit agents GitHub repo here: LangGraph Integration Example. Feel free to reach out if you want a hand with the setup or if you have any specific ideas you’re exploring—I’m here to help! Sources: LangChain integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-langchain/livekit/plugins/langchain/py.type... | Large language model (LLM) integrations | LiveKit Docs
p
Can you show me an example using Cartesia and multi agents in python
t
Here is an example of using Cartesia with multi-agents in Python for LiveKit: 1. First, install the required plugin:
pip install "livekit-agents[cartesia]~=1.2"
2. Next, set your API keys in a
.env
file for Cartesia, OpenAI, Deepgram, and LiveKit. 3. Then, define multiple agents (like Greeter, Expert, Support) each with their own Cartesia TTS voices and make sure they keep the context between agents. Here’s a simplified example to get you started:
Copy code
from livekit.agents import Agent, AgentSession
from livekit.plugins import cartesia, deepgram

class GreeterAgent(Agent):
    def __init__(self):
        super().__init__(
            instructions="You are a friendly greeter.",
            stt=deepgram.STT(),
            tts=cartesia.TTS(voice="greeter-voice-id")
        )

class ExpertAgent(Agent):
    def __init__(self):
        super().__init__(
            instructions="You are a technical expert.",
            stt=deepgram.STT(),
            tts=cartesia.TTS(voice="expert-voice-id")
        )

async def entrypoint(ctx):
    session = AgentSession()
    await session.start(agent=GreeterAgent(), room=ctx.room)
If you want a full example with smooth agent transitions and context preservation, just check out the LiveKit agents GitHub repo or feel free to ask me for more details—I’m here to help! Sources: examples/voice_agents/restaurant_agent.py | Cartesia STT integration guide | LiveKit Docs | complex-agents/personal_shopper/README.md