SolaFix AILanguage: English

Home › Grok › API

APIChecked

Grok API: API Key, CLI and Pricing

Looking for the Grok API, a Grok API key or the Grok CLI? As of December 2026, the short answer is this: the API is a separate door from the Grok chat app. You create a key in Grok Console, install the xAI SDK with one command, and send requests to the API address. Plan prices are listed below.

SolaFix AI is an independent guide and is not affiliated with SpaceX Super Intelligence LLC (formerly xAI Corp.).

At a glance

The Grok chat app is for talking to Grok yourself. The API is for programs that talk to it.

You create an API key in Grok Console and send it as XAI_API_KEY or as a Bearer token. The SDK install command is pip install xai-sdk.

The Free plan has no Grok API access. Plus ($8 a month) and higher plans include it.

Not a developer? The app and website are all you need.

Live status is on the official page. Use the button below.

Open the official Grok status page

01Grok API vs the Grok app: what is the difference?

Think of a restaurant. The Grok app is the dining room: you sit down, ask the waiter for something and eat. The API (a way for one program to talk to another program) is the drive-through window. Your own code pulls up, places an order and drives off with the answer. Same kitchen, two doors.

That is why the two are set up in different places. You chat on grok.com or in the phone app. You build with the API through the developer docs and Grok Console (the web page where API keys are made).

For example

Ethan, a hobby coder who builds small tools on weekends, wants a script that sends questions to Grok on its own. A program has to place the order, so he needs the API and a key.

Megan, a shop owner who drafts product text on her phone, just types into Grok and copies the reply. She does not need the API at all. The app does the job.

Luis, a student who tried the Free plan, hears that Grok has an API and wants to try it. On the Free plan there is no Grok API access, so he would need to move up to a paid plan first.

02How to get a Grok API key

An API key is like a building access card. Your program shows the card at the door, and the building lets it in and knows whose account the visit belongs to. Keys are made in Grok Console, not inside the chat app.

Sign in to Grok Console. If you are working with a team, make sure you are in the right team.

Create an API key there. If you ever need a fresh one, you can create or rotate the key in the same place.

Give the key to your program as XAI_API_KEY, or send it in the request header as Authorization: Bearer <XAI_API_KEY>.

Point your requests at the API base URL, https://api.x.ai/v1.

Treat the key like a house key. Never paste it into a public page or share it in a chat. Anyone who holds it can send requests on your account.

The official API docs are the best place to start. They cover the keys, the SDK and the current models.

Open the xAI API docs

This opens the official developer documentation.

03Grok CLI and SDK: the install command

A CLI (command line interface) is a tool you run by typing commands instead of clicking buttons. An SDK (software development kit) is a ready-made toolbox that saves you from writing every request by hand. For Python, the xAI SDK installs with a single line.

Install the xAI SDKpip install xai-sdk

API base URLhttps://api.x.ai/v1

Key variableXAI_API_KEY

Auth headerAuthorization: Bearer <XAI_API_KEY>

The docs also describe the Responses API and name Grok 4.7 as the latest API model as of December 2026. Model names change, so check the docs before you hard-code one.

You may also see Grok Build in the plan lists. It is part of the subscription plans, and third-party models used inside Grok Build are billed separately.

Copying an install command from a random website is like trying a stranger's key in your front door. Use the command from the official docs.

04Grok API pricing: where to look

API fees have their own price page, apart from the plan prices for the app. It is a different menu: the dining room sells plans, the drive-through window has its own price board. This page does not list per-request prices, so check the official API pricing page for current rates.

Current API rates live on the official API pricing page.

See Grok API pricing

This opens the xAI pricing page for the API.

Plans matter too, because API access is tied to them. Here are the US web prices for December 2026, per month and before tax.

Free ($0)No Grok API access

Plus ($8)Includes Grok API access

Premium ($30)4x the usage of Plus

Super ($100)15x the usage of Plus

Ultra ($200)50x the usage of Plus

For the full comparison, see our Grok pricing guide. The iPhone App Store may show different plan names, such as SuperGrok, with prices that differ from the website.

05Grok API errors and what they mean

When a request fails, the error number tells you which door you got stuck at. These are the messages the developer docs describe, with the usual fix for each.

400 Bad Request

Something in the request is wrong: an argument, a URL parameter, or an incorrect API key. Check the request body and the endpoint URL against the API reference, and confirm the key is valid.

401 Unauthorized

The Authorization header is missing, or the token is not valid. Send Authorization: Bearer <XAI_API_KEY>. If needed, create or rotate the key in Grok Console.

403 Forbidden

The key or the team lacks permission, or it has been blocked. Ask the team administrator to check access and permissions, and check whether the key or team is blocked.

404 Not Found

The model or endpoint could not be found. Check the model name, then check the endpoint path for spelling and availability.

415 Unsupported Media Type

A POST request had an empty body or no JSON content type. Send a valid body and set Content-Type: application/json.

429 Too Many Requests

You went over the request rate or the token limit. Slow down and wait a little longer between retries (this is called backoff). You can also review your team's limits in Grok Console or ask for a higher limit.

Two upload messages come from the chat side, not the API: "File type not supported" and "An attachment couldn't be loaded". Convert the file to a format such as PDF or TXT, or try the same file on another platform.

06Grok down or not logging in?

If the app itself is acting up, check the official status page first. Our Is Grok down guide shows the order to check things in. For sign-in trouble, see Grok login help.

07Where to get help with the API

For API questions, the xAI API Developer Discord has a #help channel. For API bugs, the developer debugging guide points to an API Bug Report email address. Include the request, the response and any logs, so the team can see what happened. For problems with the app or your subscription, use the Help area on the website or in the app.

Q&AFAQ

Is the Grok API free?

The Free plan does not include Grok API access. Plus, at $8 a month, and the higher plans include it. Per-request fees are on the official API pricing page.

Where do I get a Grok API key?

Create it in Grok Console. Then use it as XAI_API_KEY or send it as an Authorization Bearer token.

What is the Grok CLI or SDK install command?

For Python, the xAI SDK installs with pip install xai-sdk. The API base URL is https://api.x.ai/v1.

How much does the Grok API cost?

Check the official xAI API pricing page for current rates. This page does not list per-request prices.

What does a Grok API 401 error mean?

The Authorization header is missing or the token is invalid. Send Authorization: Bearer <XAI_API_KEY>, and rotate the key in Grok Console if needed.

Do I need the API if I only want to chat with Grok?

No. The website and app are for chatting. The API is for programs that talk to Grok directly.

Related guides

Grok pricing and plans

Is Grok down? Status and fixes

Grok login help

Grok: everything in one place

Prices, limits and links were checked on December 6, 2026. SolaFix AI is not affiliated with SpaceX Super Intelligence LLC (formerly xAI Corp.).