xAI
xaiAliasesgrok
YAML config
evalguard.config.yaml
providers:
- id: xai:grok-2
config:
apiKey: ${XAI_API_KEY}TypeScript usage
typescript
import { createProvider } from "@evalguard/core";
const provider = createProvider("xai", process.env.XAI_API_KEY);
const response = await provider.chat(
[{ role: "user", content: "Hello" }],
{ model: "grok-2" },
);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
- 011. Sign up for an account on the xAI platform.
- 022. Obtain your API key from the dashboard after logging in.
- 033. Review the API documentation to understand the endpoints and usage.
- 044. Set up your development environment with the necessary libraries for API calls.
- 055. 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