Get your xAI / Grok API key
Get your xAI API key for Grok 4.3, Grok 4.20, and Grok 4.1 Fast
xAI provides API access to Grok models. Their API is OpenAI-compatible, meaning you can use the same SDKs and formats. Accounts are managed through the xAI Console.
xai-New accounts get $25 in free promotional credits (no payment method needed). Credits expire after 30 days.
Available models on Mykey
Step-by-step guide
Click on the API Tab
From the xAI homepage, click on the API tab.
- Go to https://x.ai
- Click on the "API" tab in the navigation

Select Start Building Now
Navigate to the sign-in page from the API page.
- Click the "Start building now" button above the fold
- You'll be directed to xAI's sign-in page

Create or Log Into Your xAI Account
Authenticate to access your API console.
- Sign in with your email and password
- Or authenticate via X (Twitter) or Google OAuth

Select Manage API Keys
Find the API Keys section in the console.
- Look for "Manage API keys" below the welcome message
- Click on it to open the API Keys management page
Create Your API Key
Generate your key with appropriate permissions.
- Click "Create API Key"
- Name your key
- Select the endpoints and models you want to grant access to
- Preview and generate the key

Copy and Save Your Key
Your key is shown only once.
- Copy the key immediately — it starts with xai-...
- Store it securely in a password manager
- Never share it or expose it in screenshots
New accounts get $25 in free promotional credits (expires in 30 days). No payment method required to start.
Add Your Key to Mykey.chat
Connect your key in Mykey settings.
- In Mykey.chat, go to Settings → API Keys
- Select xAI / Grok as the provider
- Paste your API key
- Click Save
Pricing
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
grok-4.1-fast | $0.20 | $0.50 |
grok-code-fast-1 | $0.20 | $1.50 |
grok-3-mini | $0.30 | $0.50 |
grok-4.3 | $1.25 | $2.50 |
grok-4.20 | $2.00 | $8.00 |
API Details
Common issues
| Issue | Fix |
|---|---|
| 401 Unauthorized | Promotional credits expired — add a payment method and purchase credits |
| 429 Too Many Requests | Rate limit hit — new accounts have conservative limits |
| Key not visible after creation | Keys are shown once — create a new one if lost |
| Credits expired | Promotional credits last 30 days — add billing to continue |
Frequently asked questions
Do I need to pay to use the xAI API?
No. New accounts receive $25 in free promotional credits with no payment method required. Credits expire after 30 days. After that, you can add a payment method or opt into the data-sharing program for additional credits.
Is the xAI API OpenAI-compatible?
Yes. xAI's API is OpenAI-compatible, meaning you can use the same SDKs and request formats. Mykey handles this automatically when you select xAI as your provider.
Ready to connect your xAI / Grok key?
Sign in to Mykey and paste your API key in Settings. It will be encrypted with AES-256 immediately.
Sign in to Mykey