xAI Grok 3 Mini
Add the following code to your Python file
1from kern.agent import Agent2from kern.models.xai import xAI3from kern.tools.yfinance import YFinanceTools45agent = Agent(6 model=xAI(id="grok-3-mini-fast", reasoning_effort="high"),7 tools=[8 YFinanceTools(9 stock_price=True,10 analyst_recommendations=True,11 company_info=True,12 company_news=True,13 )14 ],15 instructions="Use tables to display data.",16 markdown=True,17)18agent.print_response("Write a report comparing NVDA to TSLA", stream=True)Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall dependencies
1uv pip install -U kern-ai openaiExport your xAI API key
1export XAI_API_KEY="your_xai_api_key_here"1$Env:XAI_API_KEY="your_xai_api_key_here"Run Agent
1python xai.py