can grok ai voice have custom tools or only xAI to...
# ask-ai
a
can grok ai voice have custom tools or only xAI tools?
✅ 1
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — quick clarification: are you asking about Grok used via LiveKit Agents (voice agents) or Grok as a standalone service? Answering both briefly: • Grok Voice Agents support custom tools you define in your agent code (using
@function_tool
in Python or
llm.tool()
in Node.js). • LiveKit also provides xAI provider tools (e.g.,
XSearch
,
WebSearch
,
FileSearch
), but those provider tools are currently available only in Python. • You can mix custom tools with xAI provider tools when building agents. If you want, tell me which runtime you’re using (Python or Node.js) and an example tool you need — I’ll give a short code example for wiring it into a Grok voice agent. Sources: Function tool definition | LiveKit Documentation | xAI LLM | LiveKit Documentation | https://docs.livekit.io/agents/models/realtime/plugins/xai.md|, with interactive elements
a
show me an example of a grok voice agent with a tool that is a handoff
t
Thanks — I’ll show a concise Python example of a Grok (xAI) voice agent that uses a custom handoff tool to transfer control to another agent.
Copy code
from livekit.agents import Agent, AgentSession, function_tool, RunContext
from livekit.plugins import xai

class SupportAgent(Agent):
    def __init__(self):
        super().__init__(instructions="You are a technical support specialist.")

class BillingAgent(Agent):
    def __init__(self):
        super().__init__(instructions="You are a billing specialist.")

class TriageAgent(Agent):
    def __init__(self):
        super().__init__(instructions="You are a triage agent using Grok voice. Route callers to the right team.")

    @function_tool()
    async def handoff_to_support(self, context: RunContext):
        """Return an Agent instance to trigger a handoff to Support."""
        return SupportAgent(), "Handoff: connecting you to technical support."

    @function_tool()
    async def handoff_to_billing(self, context: RunContext):
        """Return an Agent instance to trigger a handoff to Billing."""
        return BillingAgent(), "Handoff: connecting you to billing."

# Create the session with the Grok realtime voice model
session = AgentSession(
    llm=xai.realtime.RealtimeModel(voice="Ara"),  # Grok voice model via xai plugin
    agent=TriageAgent()
)

# Run the session according to your app's realtime/telephony wiring
# e.g., await session.run(connection)
Notes: • The handoff tool returns a new Agent instance (and an optional message) — returning an Agent triggers the handoff pattern. • Use
xai.realtime.RealtimeModel()
to wire Grok voice into the AgentSession. If you’d like, tell me whether you want a Node.js example or a sample decision flow that triggers which handoff to call. Sources: Introducing the Grok Voice Agent API in partnership with xAI | LiveKit | xAI Grok Voice Agent API plugin | LiveKit Documentation | The Handoff Pattern for Voice Agents That Replaces IVR Menus | LiveKit | Agents and handoffs | LiveKit Documentation, with interactive elements