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.

Key prefix:xai-
Free tier available

New accounts get $25 in free promotional credits (no payment method needed). Credits expire after 30 days.

Available models on Mykey

Grok 4.20 (Reasoning)Grok 4.20 (Non-Reasoning)Grok 4.1 Fast (Reasoning)Grok 4.1 Fast (Non-Reasoning)Grok 4.3

Step-by-step guide

1

Click on the API Tab

From the xAI homepage, click on the API tab.

  1. Go to https://x.ai
  2. Click on the "API" tab in the navigation
xAI homepage with the API tab highlighted
2

Select Start Building Now

Navigate to the sign-in page from the API page.

  1. Click the "Start building now" button above the fold
  2. You'll be directed to xAI's sign-in page
xAI API page showing the Start building now button
3

Create or Log Into Your xAI Account

Authenticate to access your API console.

  1. Sign in with your email and password
  2. Or authenticate via X (Twitter) or Google OAuth
xAI sign-in page with email, X, and Google options
4

Select Manage API Keys

Find the API Keys section in the console.

  1. Look for "Manage API keys" below the welcome message
  2. Click on it to open the API Keys management page
5

Create Your API Key

Generate your key with appropriate permissions.

  1. Click "Create API Key"
  2. Name your key
  3. Select the endpoints and models you want to grant access to
  4. Preview and generate the key
xAI API key creation popup showing name, endpoints, and model selection
6

Copy and Save Your Key

Your key is shown only once.

  1. Copy the key immediately — it starts with xai-...
  2. Store it securely in a password manager
  3. 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.

7

Add Your Key to Mykey.chat

Connect your key in Mykey settings.

  1. In Mykey.chat, go to Settings → API Keys
  2. Select xAI / Grok as the provider
  3. Paste your API key
  4. Click Save

Pricing

ModelInput (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

IssueFix
401 UnauthorizedPromotional credits expired — add a payment method and purchase credits
429 Too Many RequestsRate limit hit — new accounts have conservative limits
Key not visible after creationKeys are shown once — create a new one if lost
Credits expiredPromotional 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
Your keys are encrypted with AES-256 and never stored in plain text.