Example

from phi.agent import Agent
from phi.model.xai import xAI
from phi.tools.yfinance import YFinanceTools

agent = Agent(
    model=xAI(id="grok-beta"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)],
    instructions=["Use tables to display data."],
    show_tool_calls=True,
    markdown=True,
)

agent.print_response("What is the stock price of NVDA and TSLA")

xAI Params

ParameterTypeDefaultDescription
idstr"grok-beta"The specific model ID used for generating responses.
namestr"xAI"The name identifier for the xAI agent.
providerstr"xAI"The provider of the model, combining "xAI" with the model ID.
api_keyOptional[str]-The API key for authenticating requests to the xAI service. Retrieved from the environment variable XAI_API_KEY.
base_urlstr"https://api.xai.xyz/v1"The base URL for making API requests to the xAI service.

xAI is a subclass of the OpenAILike class and has access to the same params.