Özer Cem KELAHMETKELAHMET
Articles · Grok

Grok API in late 2026: Grok 4.7, custom guidelines, safety identifiers and long-context prices

xAI's Grok API now lists Grok 4.7 beside 4.6, 4.5 and 4.3, retires Grok Build 0.1 and is adding per-request moderation guidelines, including a gated cyber category. This guide explains the line-up, how Grok pricing doubles past 200K tokens and how to use the new controls.

Download Markdown
At a glance
Reading time
14 min
Sections
9
Code examples
2
Tables
2
Sources
6
Published
23 Nov 2026
In 30 seconds
What changed
Grok 4.7 appears in the API catalogue
Why it matters
For most Grok users, the decision is between Grok 4.7 and Grok 4.3.
What to do
Replace deprecated models

xAI's Grok family has moved quickly through version numbers in 2026: Grok 4.3, 4.5, 4.6 and now 4.7 all appear in the model catalogue that xAI's API publishes. In the same period the official Python SDK, xai-sdk, has gained controls that change how developers ship Grok in products: a guidelines parameter that tunes moderation per request, a safety_identifier that ties abuse reports to an end user rather than to a whole API key, and, in its unreleased changes, a cyber category that some approved keys can set to allow.

For anyone building on Grok, the practical questions are simple. Which model should I call, what will it cost once prompts get long, and how do I stop one bad user from getting my whole key blocked? This guide answers them using xAI's own SDK changelog, its model type list and the prices that xAI's language-models endpoint feeds into the LiteLLM catalogue.

One caution up front. Several news sites report a coming "Grok 4.8" or "Grok 5". We could not confirm either in a primary source, so this article does not discuss them.

What happened

Grok 4.7 appears in the API catalogue (week of 16 November 2026)

Industry newsletters reported Grok 4.7 "landing" in the week of 16 November. The LiteLLM catalogue, which reads xAI's api.x.ai/v1/language-models endpoint, lists grok-4.7 with a 500,000-token context, $2 per million input tokens and $6 per million output tokens, rising to $4 and $12 above 200,000 tokens. The official Python SDK's ChatModel type list had not yet added grok-4.7 at the time of writing; its newest entry is grok-4.6. Type lists are editor hints only, so the string still works.

Grok Build 0.1 reaches its deprecation date (19 November 2026)

LiteLLM records a deprecation date of 19 November 2026 for grok-build-0.1, the coding model the SDK added in May 2026. Its earlier sibling grok-code-fast-1 carries a deprecation date of 15 May 2026. Code that still calls either should move to a current Grok 4.x model.

A gated cyber category for guidelines (unreleased, after 23 October 2026)

The SDK's "Unreleased" changelog section adds "the cyber guideline category and the allow behavior". It says {"type": "policy", "category": "cyber", "behavior": "allow"} "is accepted only for API keys enabled for it; other keys get PERMISSION_DENIED". The nsfw, violence and profanity categories "still accept only decline".

Guidelines and safety identifiers ship in the SDK (23 October 2026)

Version 1.21.0 added a guidelines parameter to client.chat.create "for custom moderation controls" and a safety_identifier, "an opaque, stable string that your application assigns to the end user behind a request, so xAI can attribute a policy violation to that user instead of to your whole API key". The changelog notes it is the "same field as OpenAI's safety_identifier".

The Grok line-up and its prices

The table lists the current chat models, with values from xAI's language-models endpoint as recorded in LiteLLM. All accept text and images and return text. None has open weights.

Table 1. The Grok line-up and its prices
Model ID Context window Input / output per 1M (up to 200K) Input / output per 1M (above 200K) Cached input per 1M Modalities Licence
grok-4.7 500,000 $2 / $6 $4 / $12 $0.50 Text, image in; text out Proprietary, API only
grok-4.6 500,000 $2 / $6 $4 / $12 $0.50 Text, image in; text out Proprietary, API only
grok-4.5 500,000 $2 / $6 $4 / $12 $0.30 Text, image in; text out Proprietary, API only
grok-4.3 1,000,000 $1.25 / $2.50 $2.50 / $5 $0.20 Text, image in; text out Proprietary, API only
grok-build-0.1 (deprecated) 256,000 $1 / $2 $2 / $4 $0.20 Text, image in; text out Proprietary, API only

Three things stand out.

Newer is not more expensive. Grok 4.5, 4.6 and 4.7 share the same token prices. Only the cache-read price differs, rising from $0.30 to $0.50 between 4.5 and 4.6.

Grok 4.3 has the biggest window. It accepts a million tokens, twice the newer models, and is cheaper per token. For very long documents that do not need the newest model's reasoning, it is still the economical choice.

Output is cheap relative to rivals. At $6 per million output tokens below 200K, Grok's output price is three times its input price. Many competitors charge four or five times input for output, which matters for verbose reasoning workloads.

How Grok's long-context pricing works

Grok charges by the size of the prompt. When a request crosses 200,000 tokens, both input and output prices double for that request. It is like a mobile plan that bills the whole call at a higher rate once it passes an hour, not just the extra minutes.

A worked example

A team summarises a 300,000-token contract on Grok 4.7 and gets a 4,000-token summary.

  • The prompt is above 200K, so the higher rates apply: $4 input and $12 output per million.
  • Input: 0.3 million × $4 = $1.20
  • Output: 0.004 million × $12 = $0.048
  • Total: about $1.25

If the team splits the contract into two 150,000-token halves and summarises each, both requests stay under 200K:

  • Input: 2 × 0.15 million × $2 = $0.60
  • Output: 2 × 0.004 million × $6 = $0.048
  • Total: about $0.65, before the cost of merging the two summaries

On Grok 4.3, the whole 300,000-token contract also crosses 200K, so it pays $2.50 and $5: 0.3 × $2.50 + 0.004 × $5 = $0.75 + $0.02 = $0.77.

The lesson is that chunking at the price boundary can halve costs, but only if the task tolerates splitting. Cross-document reasoning, such as finding contradictions between clause 3 and clause 40, may need the whole text in one window. Our guides to chunking strategies and the KV cache explain why long prompts cost more to serve.

Cached input

Cached input on Grok 4.7 costs $0.50 per million against $2 for fresh input, a 75% discount. Long system prompts and tool definitions that repeat across calls are the obvious candidates. See our page on prompt caching for how prefix caches work.

How the new safety controls work

Guidelines: per-request moderation settings

Every hosted model has default behaviour on sensitive topics. The guidelines parameter lets a developer adjust it for one request. Each entry is a small dictionary:

from xai_sdk import Client
from xai_sdk.chat import system, user

client = Client()  # reads XAI_API_KEY

chat = client.chat.create(
    model="grok-4.6",
    messages=[system("You are a support assistant for a children's education app.")],
    guidelines=[
        {"type": "policy", "category": "violence", "behavior": "decline"},
        {"type": "policy", "category": "nsfw", "behavior": "decline"},
        {"type": "policy", "category": "profanity", "behavior": "decline"},
    ],
    safety_identifier="u_7f3a9c2e",  # hash of your internal user ID
)
chat.append(user("Can you help me with my homework on volcanoes?"))
print(chat.sample().content)

The rules, as the changelog states them:

  • The general categories are nsfw, violence and profanity, and their only behaviour is decline. In other words, guidelines can make Grok stricter than its default, not looser, for these topics.
  • A category you leave out keeps the model's default behaviour.
  • An unknown category or behaviour raises ValueError in the SDK.
  • The API returns INVALID_ARGUMENT for a repeated category or for requests that cannot use guidelines, "such as a multi-agent model, stop, or defer()".

The cyber exception

The unreleased cyber category is the first that accepts allow. That suggests a model that declines some security requests by default and can be opened up for approved keys, such as those of security vendors doing penetration testing or malware analysis. Keys that are not enabled get PERMISSION_DENIED. Other labs have moved in the same direction with gated security models; our article on AI models that find vulnerabilities covers that trend.

Safety identifiers: protecting the whole key

Without a user identifier, every policy violation counts against your API key. One abusive user of a consumer app can get the whole app throttled or banned. A safety_identifier lets xAI see that the violations come from one end user. The changelog is specific about what to send: "a hash of your internal user ID, never an email address or display name". The legacy user parameter still works.

This is like a shop giving each customer a loyalty number rather than writing all purchases under the shop's own name. If one customer misbehaves, the problem stays with that number. Our pages on guardrails and AI governance place these controls in a wider safety design.

Other controls worth knowing

The SDK has added several features through 2026 that change cost and behaviour:

Table 2. Other controls worth knowing
Feature SDK version and date What it does
reasoning_effort="xhigh" 1.18.0, 13 August 2026 Highest reasoning effort, "supported by models such as grok-4.6"
service_tier="priority" 1.17.0, 12 June 2026 Priority processing "at a higher token price"; responses report the tier actually used
chat.compact_context() 1.15.0, 30 May 2026 Compacts a conversation into opaque encrypted_content reusable in later requests
Image generation tool 1.19.0, 18 August 2026 Lets agentic requests generate and edit images server side

Context compaction deserves attention for agents. Instead of resending a long history, you send an encrypted summary that the server can read. The response reports how many messages were dropped. It saves tokens, but you lose the ability to inspect exactly what the model still "remembers", which makes debugging harder.

Choosing between Grok models

A simple way to pick is to start from the job, not the version number.

Interactive chat and agents with moderate context. Start with Grok 4.7 or 4.6. They share prices, so the deciding factor is quality on your own tests and the slightly higher cache-read price compared with Grok 4.5. If your system prompt and tools are long and repeated, Grok 4.5's $0.30 cache-read price can make it cheaper in practice.

Long documents and archives. Start with Grok 4.3. Its 1M-token window holds twice as much as the newer models, and even above 200K tokens its $2.50 input price is below Grok 4.7's $4. Check that its answers are good enough for your task before committing.

Hard reasoning. Try the newest model at reasoning_effort="xhigh" and compare it with a lower effort on the same prompts. Reasoning tokens are billed as output, so at $6 or $12 per million they cost less on Grok than on most rivals, but they still add up on long runs.

Whatever you choose, keep the model name in configuration rather than code. xAI has shipped a new Grok 4.x version every one to three months in the second half of this year, and a quick switch is worth more than a perfect first pick. Our LLM routing page shows how to send each request to the cheapest model that can handle it.

What it means in practice

For most Grok users, the decision is between Grok 4.7 and Grok 4.3. Grok 4.7 is the newest model at $2 and $6 with a 500K window. Grok 4.3 costs less and accepts a million tokens. Without independent benchmark results for 4.7, which we could not find in a verifiable source, the right move is to test both on your own tasks.

For product teams with many end users, the safety_identifier is the most important change of the autumn. It costs one line of code and protects the key that the whole product depends on.

For security vendors, the cyber category may open legitimate use cases that default moderation blocks, but only after xAI enables a key. Plan for an approval process, not a flag you can set yourself.

What to do now

  1. Replace deprecated models. Search your code for grok-build-0.1 and grok-code-fast-1 and move to a current Grok 4.x model.
  2. Pin explicit model versions. Prefer grok-4.7 or grok-4.6 over -latest aliases in production so behaviour does not change underneath you.
  3. Send a safety identifier on every request. Use a stable hash of your internal user ID, never an email address.
  4. Set guidelines for sensitive audiences. Apps for children, schools or regulated industries should explicitly decline the categories they never want.
  5. Watch the 200K boundary. Log prompt sizes and check how many requests cross 200,000 tokens, where prices double.
  6. Compare Grok 4.3 for long documents. Its 1M window and lower price may beat Grok 4.7 for summarising very long text.
  7. Use priority tier only where latency matters. Measure the price difference on your invoice before enabling it widely.
  8. Apply for cyber access only with a clear use case. If you build security tools, prepare documentation of your controls before asking xAI to enable the category.

Risks and open questions

Grok 4.7 lacks verified benchmarks in our sources. We found no independent results we could check. Treat comparative claims with care until evaluators such as Artificial Analysis or LMArena publish results with their methods.

Rumoured models are not facts. Reports of Grok 4.8 and Grok 5 dates circulate widely. Do not plan migrations around them until xAI publishes model IDs and prices.

Guidelines cannot loosen general categories. Developers expecting to unlock mature content through guidelines will find that only decline is accepted for nsfw, violence and profanity.

Compaction hides state. Encrypted context is efficient but opaque. Keep your own logs of what the user said so you can audit agent decisions.

Watch next: a tagged SDK release that ships the cyber category, grok-4.7 in the SDK's model list, xAI's own model card for Grok 4.7, and independent evaluations of the 4.x line.

Frequently asked questions

What is the newest Grok model in the API?

xAI's language-models endpoint, as recorded by LiteLLM, lists grok-4.7 at $2 per million input tokens and $6 per million output tokens with a 500,000-token context. The official Python SDK's type list stops at grok-4.6, but any model string the API accepts will work.

Why does Grok cost more for long prompts?

xAI charges a higher rate for requests above 200,000 tokens. For Grok 4.5, 4.6 and 4.7, input rises from $2 to $4 and output from $6 to $12 per million tokens. The higher rate applies to the whole request.

What does the guidelines parameter do?

It lets you set moderation behaviour per request. For nsfw, violence and profanity the only allowed behaviour is decline, which makes the model stricter. An unreleased cyber category also accepts allow, but only for API keys that xAI has enabled.

What should I send as a safety_identifier?

Send a stable, opaque value such as a hash of your internal user ID. xAI's changelog says never to send an email address or display name. The field lets xAI attribute violations to one end user instead of your whole API key.

Can I download Grok model weights?

The current Grok 4.x models are available only through xAI's API and partners. They are proprietary, so you cannot download or self-host them. If you need weights, look at open models such as Llama, Qwen, DeepSeek, Mistral or Kimi.

Summary

xAI's Grok API in November 2026 offers Grok 4.7, 4.6 and 4.5 at $2 and $6 per million tokens, doubling above 200,000 tokens, and Grok 4.3 at $1.25 and $2.50 with a 1M-token window, while Grok Build 0.1 reached its deprecation date on 19 November. The SDK's guidelines and safety_identifier fields let developers make moderation stricter per request and protect their key from individual abusers, and an unreleased cyber category will let approved keys allow security work. Pin versions, send safety identifiers, watch the 200K boundary and test Grok 4.7 against Grok 4.3 on your own tasks.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 23). Grok API in late 2026: Grok 4.7, custom guidelines, safety identifiers and long-context prices. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/grok-api-guidelines-safety-identifier-lineup

BibTeX
@online{kelahmet2026grok,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{Grok API in late 2026: Grok 4.7, custom guidelines, safety identifiers and long-context prices}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/grok-api-guidelines-safety-identifier-lineup}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 23, 2026
Type to search.
    ↑↓ navigate↵ open