xAI is a platform for providing endpoints for Large Language models.

Authentication

Set your XAI_API_KEY environment variable. You can get one from xAI here.

Example

Use xAI with your Agent:

Params

For more information, please refer to the xAI docs as well.

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 also supports all the params of OpenAI.