Table of contents

Grok consists of a family of large language models (LLMs) developed by xAI.
While the models are helpful within X (formerly Twitter), they can offer even more value when they’re integrated with your product or your internal applications.
For either integration scenario, you’ll need to start by creating your API key on xAI. We’ll help you do just that in 5 simple steps!
From the xAI homepage, click on the “API” tab.

{{this-blog-only-cta}}
Above the fold, you should see a button that says, “Start building now.” Once you select that, you’ll be directed to xAI’s sign in page.

You can sign in in one of three ways: enter your email address and password manually or go through an OAuth flow to authenticate either via your Twitter or Google account.

Related: How to create an API key in Mistral AI
Below the welcome message, you should see a small text block that reads, “Manage API keys.” Click on this.

Once you select “Create API key,” you should see a pop-up that prompts you to name the key, select the endpoints you want to grant it, and pick the models it can use. Finally, you’ll be able to preview and generate the key.
Once you’ve created it, you'll be able to view its usage and edit, disable, or delete it. You can also create an entirely new key by clicking on Create API key.

Related: How Grok 4.5 compares to Sonnet 5
Before building to Grok’s API, it’s worth familiarizing yourself with the following:
Grok’s pricing varies depending on the type of output you’re hoping to generate and the specific model you want to use.
For instance, Grok 2’s price per million text tokens is $2 while Grok Beta's is $5.

Learn more about Grok’s pricing.
Every user is currently limited to 1 request per second and either 60 or 1,200 requests per hour (depending on the model).

You can get all kinds of errors. This includes the following:
Discover additional API error codes and how you can go about addressing them in this blog post.
Merge Gateway is a single endpoint and control plane for production LLM workloads, designed to help teams route traffic intelligently, control spend, and understand what’s happening on every request.

It offers:
Try Merge Gateway for free today!
Dynamically route each request to the best-fit model (including Grok’s models) to reduce spend without compromising performance via Merge Gateway.