xAI
xAI provides access to the Grok family of language models designed for reasoning and real-time information processing. Braintrust integrates seamlessly with xAI through direct API access, wrapper functions for automatic tracing, and proxy support.
Setup
To use xAI models, configure your xAI API key in Braintrust.
- Get an xAI API key from xAI Console
- Add the xAI API key to your organization's AI providers
- Set the xAI API key and your Braintrust API key as environment variables
API keys are encrypted using 256-bit AES-GCM encryption and are not stored or logged by Braintrust.
Use xAI with Braintrust AI proxy
The Braintrust AI Proxy allows you to access xAI models through a unified OpenAI-compatible interface.
First, install the braintrust
and openai
packages.
pnpm add braintrust openai
Then, initialize the client and make a request to a xAI model via the Braintrust AI Proxy.
Trace logs with xAI
Trace your xAI LLM calls for observability and monitoring.
When using the Braintrust AI Proxy, API calls are automatically logged to the specified project.
The Braintrust AI Proxy is not required to trace xAI API calls. For more control, learn how to customize traces.
Evaluate with xAI
Evaluations distill the non-deterministic outputs of xAI models into an effective feedback loop that enables you to ship more reliable, higher quality products. Braintrust Eval
is a simple function composed of a dataset of user inputs, a task, and a set of scorers. To learn more about evaluations, check out the Experiments guide.
To learn more about tool use, multimodal support, attachments, and masking sensitive data with xAI, visit the customize traces guide.
Models and capabilities
Model | Multimodal | Reasoning | Max input | Max output | Input $/1M | Output $/1M |
---|---|---|---|---|---|---|
grok-4 | 256,000 | 256,000 | $3.00 | $15.00 | ||
grok-4-latest | 256,000 | 256,000 | $3.00 | $15.00 | ||
grok-4-0709 | 256,000 | 256,000 | $3.00 | $15.00 | ||
grok-2-vision | 32,768 | 32,768 | $2.00 | $10.00 | ||
grok-2-vision-latest | 32,768 | 32,768 | $2.00 | $10.00 | ||
grok-2-vision-1212 | 32,768 | 32,768 | $2.00 | $10.00 | ||
grok-2 | 131,072 | 131,072 | $2.00 | $10.00 | ||
grok-2-latest | 131,072 | 131,072 | $2.00 | $10.00 | ||
grok-2-1212 | 131,072 | 131,072 | $2.00 | $10.00 | ||
grok-vision-beta | 8,192 | 8,192 | $5.00 | $15.00 | ||
grok-beta | 131,072 | 131,072 | $5.00 | $15.00 |