Skip to main content

Usage guide

Setup, environment variables, and Python/JavaScript/Go usage examples.

XAILLM

Text generation with xAI’s Grok models, using your own xAI API key. Good for fast conversational agents with tool calling. Authenticates with XAI_API_KEY from your environment, or an explicit api_key.

Fields

str
default:"UNSET"
Grok model name, e.g. “grok-4.3”. Defaults to ‘grok-4.3’.
str
default:"UNSET"
Base URL of the xAI API. Change it only when routing through a proxy or compatible endpoint. Defaults to ‘https://api.x.ai/v1’.
float
default:"UNSET"
Sampling temperature, 0 to 2. Lower values give more focused, repeatable replies. Defaults to 0.7.
Literal['auto', 'required', 'none']
default:"UNSET"
How the model may call tools: “auto” lets it decide, “required” forces a tool call, “none” disables tools. Defaults to ‘auto’.
int | None
default:"UNSET"
Maximum number of tokens the model may generate per reply. Leave unset for no explicit limit. Defaults to None (not set).
str | None
default:"UNSET"
How much the model thinks before answering, e.g. “none”, “low”, “medium” or “high”; supported values depend on the Grok model. Defaults to None (not set).