Live Search Agent
Code
1from kern.agent import Agent2from kern.models.xai.xai import xAI34agent = Agent(5 model=xAI(6 id="grok-3",7 search_parameters={8 "mode": "on",9 "max_search_results": 20,10 "return_citations": True,11 },12 ),13 markdown=True,14)15agent.print_response("Provide me a digest of world news in the last 24 hours.")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export XAI_API_KEY=xxxInstall dependencies
1uv pip install -U xai kern-aiRun Agent
1python cookbook/11_models/xai/live_search_agent.py