All insights

Model APIs

Grok 4 API: Current Model, First Request, and Production Checks

Find the current Grok API model to use, send a first authenticated request with the Responses API, and review model pricing, rate limits, and production considerations.

Illustration for Grok 4 api

Which Grok 4 model should you use?

If by “Grok 4 API” you mean the original Grok 4 model, note that its API slug grok-4-0709 was retired on May 15, 2026. Requests to that old slug are redirected to grok-4.3; it is not a way to keep calling the original model. For a new integration, xAI’s current quickstart uses grok-4.7 with the Responses API. An API key’s permissions can limit which endpoints and models it can access, so confirm that the key you create has the permissions your integration needs. (Retirement notice; Quickstart; API-key authorization)

The instructions below use the xAI API at api.x.ai—not GroqCloud or a third-party aggregator. They reflect the documentation available on November 9, 2026.

Make your first Grok API request

  1. Sign up at console.x.ai and load the account with API credits.
  2. Create an API key from the console’s API Keys page. Export it as an environment variable; keep it on your server or in a secret manager, not in browser or mobile app code. The xAI quickstart documents this setup.
export XAI_API_KEY="your_api_key"

The Responses API uses POST /v1/responses. This curl example sends the model and input as JSON and authenticates with a bearer key, as shown in the quickstart and Responses reference:

curl https://api.x.ai/v1/responses \\
  -H "Authorization: Bearer $XAI_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "model": "grok-4.7",
    "input": "In one sentence, explain what an API is."
  }'

The raw response is a JSON response object with fields including id, model, status, and an output array. Check that status is completed. To read the answer conveniently with Python, the quickstart documents the OpenAI SDK configuration and response.output_text:

pip install openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["XAI_API_KEY"],
    base_url="https://api.x.ai/v1",
)

response = client.responses.create(
    model="grok-4.7",
    input="In one sentence, explain what an API is.",
)

print(response.output_text)

A non-empty value printed by response.output_text confirms the SDK returned answer text. xAI recommends the Responses API as its primary interface for text generation, reasoning, and tool use. (Responses reference)

Production fit: model details, pricing, and limits

The Grok 4.7 guide lists text and image input, text output, a 500,000-token context window, and reasoning settings of low, medium, high (the default), and xhigh. (Grok 4.7 guide)

Decision point Documented detail for grok-4.7
Context window 500,000 tokens
Standard short-context text rates USD $2.00 per 1 million input tokens; $6.00 per 1 million output tokens
Cached short-context input USD $0.50 per 1 million cached input tokens
Long-context rates For prompts reaching the documented 200,000-token threshold: $4.00 per 1 million input tokens, $1.00 per 1 million cached input tokens, and $12.00 per 1 million output tokens
Endpoint rate limits Per-model limits depend on your team tier; check the xAI Console for your current limits

The pricing documentation says long-context rates apply to all tokens in a request once its prompt reaches the model’s threshold. A simple estimate for a short-context request with 100,000 input tokens and 20,000 output tokens is $0.32: (100,000 × $2 / 1,000,000) + (20,000 × $6 / 1,000,000). This assumes standard, uncached text-token rates and excludes any applicable tool-call charges. Check the pricing page for the documented threshold and current rates before budgeting.

For production, check that your API key’s endpoint and model permissions match your use, monitor token usage and costs, and review your team’s rate limits. xAI documents per-model requests-per-second and tokens-per-minute caps; exceeding a limit can return HTTP 429. Its rate-limit guidance recommends reducing request frequency or checking whether your team can raise its limit. Use bounded backoff and monitoring rather than retrying every 429 immediately. (API-key authorization; Rate limits)

If your requirement is specifically the original Grok 4 model, don’t treat grok-4.7 as an identical replacement: it is the model used in the current quickstart, while the retired grok-4-0709 slug redirects to grok-4.3. Choose based on the model your workload needs, then verify the model identifier, key permissions, pricing, and limits before launch. (Quickstart; Retirement notice)

Sources

Grok API Quickstart: Get Your API Key

Responses — Inference API REST Reference

Accounts and Authorization — Management API REST Reference

Grok 4.7 Developer Guide

API Pricing

Rate Limits

Grok Model Retirement on May 15, 2026

Contact us