xAI
xaiAliases: grok
YAML config
providers:
- id: xai:grok-2
config:
apiKey: ${XAI_API_KEY}TypeScript usage
import { createProvider } from "@evalguard/core";
const provider = createProvider("xai", process.env.XAI_API_KEY);
const response = await provider.complete({
model: "grok-2",
messages: [{ role: "user", content: "Hello" }],
});Authentication
Set XAI_API_KEY in your environment. EvalGuard validates the key on first call and surfaces typed errors for 401 / 403 / rate-limit responses (with Retry-After parsing).
Setup walkthrough
- 1. Sign up for an account on the xAI platform.
- 2. Obtain your API key from the dashboard after logging in.
- 3. Review the API documentation to understand the endpoints and usage.
- 4. Set up your development environment with the necessary libraries for API calls.
- 5. Make a test API call to ensure your setup is working correctly.
Gotchas
- Rate limits are strict; exceeding them may result in temporary access restrictions.
- Some features may not be available in certain regions due to compliance issues.
- The API may return different results based on the model version used, so ensure consistency in your calls.
Cost note
Pricing is $0.01 per 1,000 tokens for the cheapest model and $0.06 per 1,000 tokens for the flagship model.
Recommended models
- Eval / judge
- xai-gpt-3.5-turbo
- Agent / tool-use
- xai-grok-2.0
- Code
- xai-codex-1.0
- Vision
- xai-vision-1.0
LLM-generated (llm-gpt-4o) · 2026-05-23