How to get a Grok (xAI) API key

Updated · 3 min read

A Grok API key lets apps use xAI's Grok models on your own xAI account, billed per token from credits you buy. It comes from the xAI console at console.x.ai. (xAI's developer docs now appear under the SpaceXSI name; the console and API addresses are unchanged.) Searching for a free Groq key instead? That's a different company with a free plan: see the Groq API key guide.

Step by step

  1. Create an account at console.x.ai. Keys and credits belong to a team; make sure you are in the team you want to pay from.
  2. Buy credits. Open Billing → API spend management and buy prepaid credits by card (bank transfers take 2-3 business days). The same page shows your balance and has a field for promo codes.
  3. Create a key on the API Keys page and copy it.
  4. Add it to your app. Pick xAI or Grok in the app's provider list. If there is none, add a custom OpenAI-compatible provider with base URL https://api.x.ai/v1.

Is there a free Grok API?

Not today. On 2026-10-29 xAI's docs described two ways to pay, prepaid credits and monthly invoiced billing (on request through sales), and no free tier, free models or free monthly credits. Sites that promise "free Grok API keys" are sharing someone else's key or running a scam; a leaked key can be revoked at any moment, and it hands your prompts to a stranger's account.

If you want to try BYOK apps without paying, use a key that really is free, such as the Gemini free tier, Groq's free plan or OpenRouter's free models. See free AI API keys for the full list.

What it costs

Prices per million tokens on xAI's pricing page, 2026-10-29:

Model Context Input Cached input Output
grok-4.7 (flagship) 500K $2.00 $0.50 $6.00
grok-4.3 1M $1.25 $0.20 $2.50
grok-4.20 (reasoning and non-reasoning) 1M $1.25 $0.20 $2.50
grok-build-0.1 (coding) 256K $1.00 $0.20 $2.00

Once a prompt reaches 200K tokens, the whole request is billed at double these rates. Requests to xAI's US regional endpoint cost 10% more.

For a chat turn of about 2,000 tokens in and 500 out, grok-4.3 costs around $0.004 (more than 1,000 turns for $5) and grok-4.7 about $0.007. Repeated context that hits the cache is billed at the cheaper cached rate.

Keep the bill under control

  • Prepaid credits are a natural cap. With the default $0 invoiced billing limit, xAI rejects requests once your credits run out instead of charging your card.
  • Auto top-up buys more credits when your balance drops below a threshold (minimum $5 per top-up). If you turn it on, also set the maximum total of top-ups per month.
  • One key per app, so you can revoke a single key without breaking the others.
  • Keep keys out of shared documents and public code, and delete keys you no longer use.
  • Watch the Usage explorer in the console to see which app spends what.

Apps that work with your Grok (xAI) API key

  • Phở Chat

    Free with BYOK, Pro $10/month, Founder lifetime $59 (limited seats) · Web

    Visit

    AI research workspace for clinicians and researchers that cites real PubMed and DOI sources and labels unsourced claims, with BYOK support for zero markup.

    Works with:OpenAIAnthropicGoogle GeminiDeepSeek+1 more

  • Shotluma

    Free · Web · Open source

    Visit

    Free, open-source App Store screenshot editor whose AI generation runs in the browser on your own Gemini, Qwen, OpenAI, Anthropic or xAI key.

    Works with:Google GeminiQwenOpenAIAnthropic+1 more

  • big-AGI

    Free; Pro $9/month · Web · Open source

    Visit

    Multi-model AI workspace that runs, compares and merges answers from many providers using your own API keys.

    Works with:OpenAIAnthropicGoogle GeminixAI+14 more

  • Kilo Code

    Free to start, no markup on model usage · VS Code, JetBrains, CLI · Open source

    Visit

    Open-source AI coding agent for VS Code, JetBrains and the CLI. Use 500+ models at zero markup or bring your own keys.

    Works with:AnthropicOpenAIGoogle GeminiOpenRouter+8 more

  • Witsy

    Free, open source · macOS, Windows, Linux · Open source

    Visit

    Open-source desktop AI assistant and universal MCP client for macOS, Windows, and Linux. BYOK app supporting 15+ AI providers including local models via Ollama.

    Works with:OpenAIAnthropicGoogle GeminixAI+8 more

  • Kerlig

    $49 one-time (1 Mac) · macOS

    Visit

    Mac app that adds AI to any app for emails, replies and proofreading, using 350+ models with your own API keys.

    Works with:OpenAIAnthropicGoogle GeminiGroq+7 more

  • BoltAI

    One-time purchase, free trial · macOS, iOS

    Visit

    Native Mac and iOS AI app that connects to OpenAI, Claude, Gemini, Mistral, Bedrock and local models with your own keys.

    Works with:OpenAIAnthropicGoogle GeminiMistral+6 more

  • 5ire

    Free, open source · macOS, Windows, Linux · Open source

    Visit

    Free, open-source desktop AI assistant and MCP client that works with your own keys for OpenAI, Claude, Gemini, DeepSeek and more.

    Works with:OpenAIAzure OpenAIAnthropicGoogle Gemini+5 more

See all 20 apps that work with xAI

Direct key or a gateway?

A direct xAI key gives you xAI's own prices, billing controls and xAI-only tools such as X Search. If you use Grok next to GPT, Claude and Gemini, an OpenRouter key covers all of them from one balance.

Questions

Is the Grok API free?

No. On 2026-10-29 xAI's docs described only paid use: prepaid credits (the usual way) or monthly invoicing. There is no free tier or free monthly allowance in the docs. If you have a promo code, you can redeem it on the console's Billing page.

Does a SuperGrok or X Premium subscription include API access?

xAI's API docs don't list app subscriptions as a way to pay for the API. API usage is paid from your console team's credits or invoice.

Is Grok the same as Groq?

No. Grok (with a k) is xAI's model family. Groq (with a q) is a different company that runs open models fast and has a free plan; see our Groq API key guide.

What base URL do apps need for Grok?

https://api.x.ai/v1. The API works with OpenAI's SDKs, so apps that accept a custom OpenAI-compatible endpoint can use Grok with that URL and your xAI key.

Which Grok model should I pick?

grok-4.7 is xAI's flagship for code and chat ($2 input / $6 output per million tokens). grok-4.3 costs less ($1.25 / $2.50) and has a 1M-token context window.

Sources

Checked against the providers' own documentation on 2026-10-29. Prices and limits change; the links below have the current figures.

Related guides