Before you start
The xAI Console is separate from the Grok chatbot built into X. You need a Console account specifically to use the API. Plan on about 3 minutes.
Step 1, Create an xAI account
- Click Sign Up, or log in if you already have an account.
- Sign up with your X (Twitter) account, Google, or email.
- Complete email verification if prompted.
Step 2, Add billing
- Once logged in, navigate to Billing in the left sidebar or top menu.
- Click Add Payment Method and enter your credit card details.
- Add credits to your account. You can start small with $5 to $10.
xAI often provides free credits for new accounts. Check the billing page for any promotional balance before adding your own funds.
Step 3, Generate your API key
- In the sidebar, click API Keys.
- Click Create API Key.
- Give your key a descriptive name like "Workshop Key".
- Click Create to generate it.
- Your key will appear. It starts with
xai-...
Important. Copy your API key immediately and save it somewhere safe. You won't be able to see it again after you leave this page. If you lose it, you'll need to create a new one.
Step 4, Store your key safely
Good places to save your API key:
- Password manager like 1Password, Bitwarden, or LastPass
- Secure note on your computer
- Environment variable on your system, for developers
Never share your API key publicly, commit it to code repositories, or paste it into untrusted websites. Anyone with your key can use your account and run up charges.
Verify it worked
To confirm your key is live, paste it into any tool that accepts a Grok API key, or test it directly in your xAI Console.
Grok's API is compatible with the OpenAI SDK format, so many tools that support "OpenAI-compatible" APIs will work with your Grok key. Just point the base URL to
https://api.x.ai/v1.
You're building the tools. Now see where AI actually fits your business.
The free 5-minute AI Efficiency Audit scores your operations and hands you your first three moves, emailed the moment you finish. No call required.
Take the Free Audit →