xai
chat
vision
Test your xAI API key.
Test an xAI Grok API key, see Grok-2 / Grok-2-vision availability, and benchmark response latency.
Stateless proxy — keys never logged, stored, or persisted. What happens to your key →
Detected
xAI
What this key does
xAI's API is OpenAI-compatible. Grok-2 is the current general-purpose model; Grok-2-vision adds image input. Tool use, streaming, and JSON mode are supported via the standard OpenAI shapes.
How to get a xAI API key
- Sign in at console.x.ai.
- Add a payment method.
- Create a key in the API Keys section.
- Paste it here to validate.
Common errors and fixes
- 401 Unauthorized: Key is invalid, revoked, or pasted with extra whitespace. Generate a new key from the provider console and try again.
- 403 Forbidden: Key is valid but lacks permission for this resource. Check project / org / workspace scope, or that billing is set up for this key.
- 429 Too Many Requests: You hit the per-minute or per-day rate limit. Wait a moment and retry, or upgrade your tier.
- 404 Not Found: The endpoint or model id changed. Check the provider docs for the current path and model identifier.
- 5xx: The provider is having issues. Check their status page before assuming the bug is yours.
Security best practices
- Store keys in an env var or secret manager — never commit them to a repo, even a private one.
- Restrict scope: prefer per-project or per-deployment keys over a single root key shared across services.
- Rotate on a schedule (90 days is a sane default) and immediately on suspected leak.
- Audit usage in the provider console after rotation to confirm the old key has zero traffic.
- Set per-key spend limits where the provider supports them, so a leaked key has a bounded blast radius.
Pricing at a glance
xAI is mid-tier on price for chat. Image input is billed separately.
FAQ
- Is xAI OpenAI-compatible?
- Yes — base URL https://api.x.ai/v1.
- What's grok-beta?
- An older beta model — prefer grok-2-latest unless you've pinned to it.
- Does xAI support real-time search like Grok on X?
- The 'live search' preview is gated and not on by default for API keys.
- Which model has vision?
- grok-2-vision-latest.
- Is there a free tier?
- Promotional credits have come and gone. Don't depend on free tier in production.
- Can I stream from xAI?
- Yes, via the OpenAI-compatible stream:true on /v1/chat/completions.
Test other providers
Related reading
- API key security best practices for LLMsHow to store, scope, rotate, and revoke LLM API keys without leaking them through git, logs, or shared environments.
- Free LLM API keys for testing in 2026Which providers offer free credits, how long they last, and how to stretch them for prototyping without a credit card.