Grok API

How to find your Grok User ID via api auth session

Updated:

A Grok User ID is usually needed when buying or activating an xAI subscription through a third-party service: the identifier tells that service which Grok account should receive the subscription. You can find it in the api auth session response for the account signed in to your current browser.

How to get your Grok User ID

  1. 1

    Sign in to Grok

    Open grok.com and sign in to the exact account whose ID you need. If you use several browser profiles, check that you are in the right one.

  2. 2

    Open the session address

    In the same browser profile, open the address below. A signed-in session should return account data in JSON format.

    Session URL
    https://grok.com/api/auth/session
  3. 3

    Find the userId field

    Use the browser's Find command and search for userId. The response may look like the example below. Copy only the userId value, without the field name or quotation marks. All values in this example are fictional.

    Example session response
    {
      "status": "authenticated",
      "session": {
        "userId": "12345678-1234-1234-9234-123456789abc",
        "email": "alex@example.com",
        "emailDomain": "example.com",
        "givenName": "Alex",
        "familyName": "Example",
        "profileImage": "https://example.com/avatar.png"
      }
    }
  4. 4

    Check and copy the User ID

    A Grok User ID normally looks like a UUID: letters and numbers split into groups with hyphens. Confirm that the correct Grok account is open, then copy the complete value.

    Example User ID
    12345678-1234-1234-9234-123456789abc

Two ways to use Grok: a subscription or API tokens

Choose the payment model based on where you plan to use Grok. A web subscription and API usage are separate products and are billed separately.

xAI subscription

Usually paid monthly. It gives you access to Grok through xAI interfaces such as the Grok website and supported applications. A Grok User ID may be requested when a third-party service activates the subscription for your account.

Best for: using Grok directly in the xAI interface.

API tokens

Usage is measured by input and output tokens. An API key lets you connect Grok to your own code, products, scripts, IDE extensions, and AI agents.

Best for: integrations, automation, and agent workflows.

Where to buy Grok API tokens

If you need Grok in Python, JavaScript, Cursor, Cline, OpenCode, or another agent, a web subscription is not suitable: you need API access and an API key. You can pay through the official xAI developer platform or use an independent gateway through us.

Official xAI API

Create a developer account and API key with xAI, fund the official balance, and send requests to the xAI API endpoint at xAI's published rates.

Grok API Dev

Use a separate Grok API Dev account, balance, key, and OpenAI-compatible base URL. This is an independent service and is not affiliated with xAI or grok.com.

Why developers choose Grok API Dev

50% below the official rate

Published Grok 4.5 rates are $1.00 per 1M input tokens and $3.00 per 1M output tokens, compared with $2.00 and $6.00 in the official reference.

Test before topping up

A new account receives $0.25 in test credit so you can verify the key, base URL, and model first.

Pay as you go with crypto

Top up with a supported cryptocurrency without linking a bank card or buying a monthly plan. The balance is charged only for tokens processed by the API.

OpenAI-compatible

Existing clients usually need only a new base URL, API key, and model name.