US Trends

how do i get my grok api key ?

How to Get Your Grok API Key

Quick Scoop

You get your Grok API key by signing up on the official xAI cloud console and creating a key in the “API keys” section. After that, you must add credits to your account and copy the key immediately (it’s only shown once).

Step-by-Step: Getting Your Grok (xAI) API Key

1. Go to the xAI Console

  • Open your browser and go to: [https://console.x.ai.4]
  • If you’re not logged in, click Create account or Sign in.

2. Create or Log In to Your Account

You can sign up using:

  • Your X (Twitter) account
  • Email address
  • Google or Apple ID

Then:

  • Accept the enterprise terms and privacy policy.
  • Confirm you’re over 18.
  • Click Continue to enter the cloud console.

3. Navigate to the API Keys Section

Once inside the console:

  • Look at the left sidebar.
  • Click API keys (or sometimes labeled “Manage API keys”).

4. Create a New API Key

  • Click the Create API key button (usually top-right).
  • Enter a name for the key (e.g., my-grok-project, backend-test).
  • Choose permissions :
    • Often the default is “all”, which gives access to all endpoints and models.
  • Optionally set rate limits (TPM/RPM) if you want to restrict usage.

Click Create API key to finalize.

5. Copy Your Key Immediately

  • The console will show your Grok API key only once.
  • Copy it right now and store it securely:
    • Use a password manager or encrypted secrets vault.
    • Do not put it in public code, GitHub repos, or share it online.

If you leave the screen without copying, you won’t be able to see it again; you’ll need to create a new key.

6. Add Credits to Activate Your Key

Before you can call the Grok API:

  • Go to Purchase credits or similar in the console.
  • Choose a credit amount (e.g., $25, $100, $250, $500).
  • Without credits, your API key will not work for actual requests.

7. Use the Key in Your Code

When calling the xAI/Grok API:

  • Pass the key in the appropriate header (commonly Authorization or x-api-key, depending on the SDK/docs).
  • Follow the official Grok API documentation for endpoint URLs and request formats.

Common Mistakes & Tips

  • Not logging in correctly : Make sure you’re using the account linked to your X/Gmail/etc. that you want associated with the API usage.
  • Not adding credits : Many people create the key but forget they must add funds before it works.
  • Not copying the key : If you don’t copy it immediately, you lose it and must recreate a new key.
  • Sharing the key : Never share your Grok API key publicly or commit it to public repositories.

Where This Is shown in the UI

  • URL: https://console.x.ai → left menu → API keys
  • Button: Create API key in the top-right of that page.

Information gathered from public forums or data available on the internet and portrayed here.