Create Grok API Key: Guide for WordPress and xAI API Integration
This guide explains how you create a Grok API Key from xAI and add it to your WordPress plugin.
Short & to the point
- Open xAI Console and sign in: Go to the xAI Console and sign in with xAI, X/Twitter, Google or email.
- Check credits and team: Make sure your team has API access and that credits or billing are set up.
- Open API Keys: After login go to API Keys or Manage API keys.
- Create key: Click Create API key, give it a unique name and choose the required models or endpoints.
- Copy key: Copy the Grok API Key immediately after creating it. It will not be shown again in plain text.
- Paste the key into your WordPress software
1. Open xAI Console and sign in
Start directly at the xAI Console. If you are not signed in you will see the login first. Depending on your account you can sign in with email, Google, X/Twitter or an xAI account to sign in.
The API Key is not created in the normal X app but in the xAI developer console.
Set up payment method under Billing
After login check if credits or billing are set up. Without sufficient credits a key may be visible but API requests will still fail later.
3. Open API Keys in the xAI Console
After login open the API Keys section in the console via the left sidebar. There you see existing keys and can create new keys.
4. Create a new Grok API Key
In the API Keys area click Create API key. Give it a unique name for example by website client or environment.
5. Copy Grok API key
After creation the key is shown. Copy it immediately and treat it like a password. Once the dialog is closed the full key cannot be shown again.
6. Paste Grok API key into your WordPress plugin
Paste the Grok API key at the end into your WordPress plugin, for example neo WP AI, or store it in your own server application. It is important that the key does not end up in frontend JavaScript or in publicly visible HTML output.
For your own projects a separate key is clearer than a shared key. This way usage, permissions and rotation can later be clearly assigned to an integration.
7. Pricing, models and Batch API
Grok or xAI pricing depends on the model, token type, output format and usage. The official xAI docs list current model prices for text, coding, image, video and voice features. Example values from older articles may be out of date.
8. Observe rate limits for the Grok API
xAI currently describes rate limits per team and per model. Limits are controlled among other things via requests per second and tokens per minute. The specific limit depends on the team tier and cumulative API usage.
9. Common xAI and Grok error codes
- 401 Unauthorized: The Authorization header is missing or the token is invalid.
- 403 Forbidden: API key or team does not have the required permissions.
- 404 Not Found: Resource, endpoint or model name does not exist.
- 429 Too Many Requests: The current rate limit has been reached.
- 500 Internal Server Error: Temporary backend error on xAI side.