xAI Grok API Key Tester
Enter your xAI Grok API key below and click 'Test Key' to check if it works. This tool will send a request to xAI Grok asking, "Does this key work?" and return a response with an explanation.
💰 Once your key works, estimate what it will cost: try the xAI Grok API cost calculator.
🔑 How to Get Your API Key
2. Open API Keys and create a key
3. Copy the key (starts with xai-)
4. xAI Grok (api.x.ai) is different from Groq (console.groq.com)
Test Your API Key
🔧 Alternative: cURL Command
You can also test your API key using cURL from your terminal:
curl -sS https://api.x.ai/v1/models -H 'Authorization: Bearer {{KEY}}'
💻 How to run this command in your terminal:
- Copy the command above by clicking the "Copy" button
- Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux)
- Paste the command using Ctrl+V (Windows/Linux) or Cmd+V (Mac)
- Press Enter to execute the command
- Check the response - you'll see either a success message or an error explaining what's wrong
💡 Terminal Tips:
- Make sure you have
curlinstalled (it comes pre-installed on Mac and most Linux systems) - On Windows, you may need to install curl or use PowerShell's
Invoke-WebRequestinstead - If you see "command not found", try
curl --versionto check if it's installed
🔧 Common xAI Grok API key errors
❌ 400
Cause: The key is malformed, or you're using a Groq (gsk_) key by mistake.
Fix: Use an xai- key from console.x.ai. For gsk_ keys, use the Groq tester.
❌ 401
Cause: Invalid or revoked xAI key.
Fix: Create a new key at console.x.ai and paste it here.
❌ 429
Cause: Rate limit exceeded.
Fix: Wait a few seconds and retry.
🔑 API Key Format Guide
Your xAI Grok API key should follow the correct format:
✅ Valid Format
xai-abc123...
Starts with "xai-". xAI Grok keys start with xai- and are used at api.x.ai. This is not Groq (gsk_ keys at console.groq.com).
❌ Invalid Format
invalid_key_format
Missing required prefix, wrong length, or incorrect format
How to check if your xAI Grok API key is working
- Copy your key from console.x.ai (it starts with xai-).
- Paste it into the tester above and click Test Key.
- Green means valid; red shows the error. A 400/401 often means a Groq key was used by mistake.
❓ Frequently Asked Questions
How do I test my xAI Grok API key?
Simply paste your API key into the form above and click "Test Key". Our tool will make a test request to xAI Grok to verify your key works.
Is it safe to test my API key here?
Yes! All testing happens in your browser - we never see or store your API keys. The key never leaves your device.
What if my API key test fails?
Check the error message above. Common issues include invalid keys, expired keys, insufficient credits, or rate limiting. Use the troubleshooting guide above for specific solutions.
Can I test multiple API keys?
Yes, you can test as many keys as you need. Each test is independent and secure.
Why do I need to use the terminal?
Some providers use server-side authentication for enhanced security. The terminal method provides direct access to test your API key with full compatibility.
Use Cases
- Quickly verify if your xAI Grok API key is valid
- Troubleshoot API key-related issues with detailed error messages
- Understand xAI Grok API response codes and their meanings
- Test API connectivity before integrating AI models into your applications
- Verify model access and rate limits for your account
Supported xAI Grok Responses
This tool handles all xAI Grok error codes, including:
- 200 (OK): Key is valid and working correctly
- 201 (Created): Request successful and resource created
- 202 (Accepted): Request accepted and being processed
- 400 (Bad Request): Invalid request format or parameters
- 401 (Unauthorized): The API key is incorrect or invalid
- 403 (Forbidden): API key lacks required permissions
- 404 (Not Found): Requested resource doesn't exist
- 429 (Rate Limit Exceeded): Too many requests in a short period
- 500 (Server Error): xAI Grok servers are experiencing issues
Refer to the xAI Grok Documentation for more details.