How to Get an xAI Grok API Key: Step-by-Step Guide (2026)
To get an xAI API key for Grok, sign up at console.x.ai, create your team (the name is prefilled as Personal), then click Skip or Checkout on the Choose your plan screen. In our test on November 20, 2026, the xAI Console then generated a key starting with xai- and warned it "won't be displayed again," so copy it right away. API calls need prepaid credits.
The Grok API is billed separately from Grok itself: xAI says "the account is shared between Grok and xAI API," but "the billing is separate." We created a test team on November 20, 2026, followed every screen to the key, then deleted the team and key.
How to Get an xAI API Key in 6 Steps
Grok API keys come from the xAI Console at console.x.ai, not grok.com. xAI's quickstart says to "Sign up for an account at console.x.ai, then load it with credits to start using the API." In the live console the order was:
Sign up or sign in at console.x.ai. An existing Grok account works.
Create your team: keep or change the Team name, pick what describes you, click Continue.
Choose a plan or skip: Explore, Prototype or Build credits, or Skip.
Copy the API key from the "All set, here is your API key" screen.
Add credits from the dashboard so requests are accepted.
Store and test the key as XAI_API_KEY with a curl request.
xAI's security FAQ says "API keys are tied to specific teams," so check the team name at the top left first.
Step 1: Sign Up at console.x.ai and Create Your Team
Sign in with the account you already use for Grok, or create one. xAI's accounts FAQ adds: "To link your X account automatically to your xAI account, choose to sign up with X account."
An account with no team opened on "Create your team: Give your team a name to get started," with Team name (prefilled "Personal") and What best describes you? (Hobbyist, Student, Engineer, Business or Other).
Click Continue. Per xAI's team management FAQ, teams are where xAI "tracks API usage, processes billing, and issues invoices."
Step 2: Choose a Credit Plan or Skip
The next screen sells prepaid credits; Skip also works. It read "Choose your plan: Usage credits let you call the Grok API. Start building with as little as $5."
Card
Starts at
What the card says
Explore
$5
Try Grok in playgrounds, Full access to all models
Prototype (Popular)
$20
Build a prototype, Higher limits
Build
$100
Ship your product, Run more tests and evals
Below the cards sat an amount field ($20 preselected) and "Auto top-up when balance is below $5." xAI's billing page says credits are sold only "via Guest Checkout due to regulatory requirements," and bank transfers take 2 to 3 business days. We clicked Skip.
Step 3: Copy Your xAI API Key (Shown Only Once)
Skip did not end setup: the console created a key on the spot. The screen said "All set, here is your API key. Make sure to copy it before proceeding as it won't be displayed again," with a Copy API key button.
Leaving without copying triggers a second warning: "You haven't copied your API key. We can't show this key again after you leave. Copy it now to avoid creating a new one later," with Leave anyway and Copy and continue. The key started with xai-. xAI's Management API reference agrees: "We don't expose the full key after it has been created." A marketing email popup may also appear; dismiss it.
Step 4: Add Credits From the Team Dashboard
A key on a $0.00 balance cannot run requests, so add credits first. With the default $0 invoiced billing limit, xAI says "Your API requests will be automatically rejected once your prepaid credits are depleted."
Our dashboard showed three cards:
Merge this team with Cursor: one subscription for Grok, Cursor and X plans; "Merging a team is permanent and can't be undone." The API does not need it.
Add credits to start using the API. "Credit balance: $0.00," with an Add credits button.
Start using the API key (Ready to use), with code examples.
xAI's docs route purchases through "Billing -> API spend management," where you can also "use a promo code if you have one." Monthly invoiced billing "is disabled by default."
Step 5: Store the Key and Send a Test Request
xAI's quickstart says to "export it or add it as an environment variable."
export XAI_API_KEY="your_api_key"
Then run the quickstart request (the dashboard Code tab shows the same call):
curl https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.7",
"input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}'
OpenAI SDK: point it at base_url="https://api.x.ai/v1" with your xAI key.
Check the key:GET /v1/api-key returns its name, status and permissions (account reference).
Pick a model: xAI's models page says "For everything else, including code, use Grok 4.7." Per-model API prices are in our Grok pricing and API guide.
Testing prompts on grok.com before you put them in code? AI Toolbox (formerly ChatGPT Toolbox) adds saved prompts, folders and full-text search to Grok: 10 saved prompts, 2 top-level folders with unlimited subfolders and the first 25 search results per search on the free plan, Unlimited on Premium. 40,000+ users on the Chrome Web Store.
API Keys in the left menu lists every key on the team with Name, Key, Spend (30d), Last used and Owner. Our auto-created key was "Default API Key," masked as xai- plus four characters.
A second key needed credits in our test. On our $0 team, Create API key opened "Add credits to create your API key" with $5 (Recommended), $10 (Starter), $20 (Builder) or a Custom amount. The console estimated $5 at "2K messages, 250 images, 2.8 mins video, 63 mins of voice."
Each row's three-dot menu offers Copy key ID, View logs, View usage, Edit key, Disable key, Rotate key and Delete key. Delete asks you to confirm: "This will delete the API key and all its associated data. This action cannot be undone."
Suspect a leak? Disable key "to deactivate it temporarily" or Delete key "to remove it permanently," then create a new key. xAI works with GitHub Secret Scanning and disables leaked keys it finds.
Removed teammates: "their API keys remain with the team."
Deleting a team (Team settings, Danger zone) "will immediately delete all API keys for all users," and its prepaid credits are forfeited.
Is the xAI API Billed Separately From Grok?
Yes. One xAI account signs you in to both, but "the billing is separate for Grok and xAI API." API billing lives in the xAI Console; Grok billing is at grok.com, then Settings, Billing (or Apple or Google for app-store purchases). App chat caps are in our Grok usage limits guide.
xAI API Rate-Limit Tiers
Your rate limits rise with cumulative API spend since January 1, 2026, and "tiers never downgrade." As of November 2026, xAI's rate limits page lists:
Tier
Spend threshold
grok-4.7 requests per second
grok-4.7 tokens per minute
Tier 0
$0 (default)
150
50M
Tier 1
$50
172
53M
Tier 2
$250
208
60M
Tier 3
$1,000
312
74M
Tier 4
$5,000
500
100M
Enterprise
Available on request
On request
On request
Spend means "prepaid credit purchases or successfully fulfilled invoices." Going over a limit returns 429 Too Many Requests. The console's Models page shows your tier and per-model limits.
Keep Your Grok Prompt Drafts Organized With AI Toolbox
AI Toolbox does not create xAI API keys, add credits or change xAI's rate limits. The browser extension organizes your Grok chats on grok.com and x.com, and also works on ChatGPT, Claude and Gemini.
We skipped payment, so we did not confirm a successful API call. Our first key came free during setup, although xAI's quickstart says to load credits first, and a second key required credits. We could not see the default permissions of console-created keys (the Management API says keys created there start with no access until ACLs are added). We found no sign-up credit in xAI's docs, only a promo code field. Prepaid credits are not refundable "unless in regions required by law," and xAI stores API requests and responses for 30 days by default, without training on them.
Frequently Asked Questions
Is the xAI API key free?
Creating the key cost nothing in our test: the xAI Console generated one when we skipped the credit plan. Using it is not free. Requests draw on prepaid credits and are rejected once credits run out, and the console offered credits from $5. We found no documented sign-up credit.
Where do I find my xAI API key?
Open the xAI Console at console.x.ai, check you are in the right team, and click API Keys in the left menu. The table shows each key masked, with spend, last use and owner. The full secret is shown only once, at creation, so create or rotate a key if you lost it.
Is the xAI API billed separately from Grok?
Yes. xAI says the account is shared between Grok and the xAI API, but billing is separate. API billing and prepaid credits live in the xAI Console. Grok billing is at grok.com under Settings, Billing, or with Apple or Google if you subscribed through their app stores.
What does an xAI API key look like?
An xAI API key starts with xai- followed by a long secret. The API Keys page masks it, showing only xai- and the last four characters. xAI's quickstart stores it in an environment variable named XAI_API_KEY, and requests send it in an Authorization header as Bearer followed by the key.
Why does my xAI API key not work?
xAI's error docs say a 401 means no authorization header or an invalid token was sent. A 429 means you hit your tier's rate limit. With a zero balance and the default invoiced billing limit of $0, xAI rejects requests, so add credits. Also confirm the key belongs to the selected team.
Can I get a refund on xAI API credits?
Generally no. xAI's billing FAQ says it is not able to offer refunds on any prepaid credit purchase unless required by law in your region. Deleting a team also removes its prepaid credits, and the console warns that deletion forfeits credits and Grok Business licenses.
Bottom Line
Sign up at console.x.ai, create your team, then Skip or buy credits. Copy the xai- key once, store it as XAI_API_KEY and add credits before the quickstart curl. Manage keys under API Keys; API billing is separate from your Grok plan.
A Full Stack Developer with 7+ years of experience building AI productivity tools. Leads product development and frontend architecture for AI Toolbox, the Chrome extension suite (ChatGPT, Gemini, Grok, and Claude modules) that helps users search, organize, and export their AI conversations.
Liked this guide? Get the next one first.
Join 40,000+ readers getting practical prompts, new features, and subscriber-only deals. No spam, unsubscribe in one click.
New features and product updates before anyone else
Time-saving prompts and workflows for ChatGPT, Gemini, Claude, and Grok