Get Started

Grok 4.7

Grok 4.7 is SpaceXAI's frontier model built for coding, agentic tasks, and knowledge work.

Using the API

If you already have an API key, set the model name to grok-4.7:

import os
from xai_sdk import Client
from xai_sdk.chat import user

client = Client(api_key=os.getenv("XAI_API_KEY"))

chat = client.chat.create(model="grok-4.7")
chat.append(user("Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"))

response = chat.sample()
print(response.content)

New to the xAI API? Follow the Quickstart to create an account and make your first request.

At a glance

PropertyValue
Model namegrok-4.7
Context window500,000 tokens
Knowledge cutoffMay 2026
ModalitiesText and image input; text output
Output limitNo text output limit
Input price$2.00 / 1M tokens
Output price$6.00 / 1M tokens
ReasoningLow, medium, high (default), or xhigh
APIsResponses API, Chat Completions
ToolsFunction calling, web search, X search, code execution

Rate limits and live pricing for your team are on the model detail page and Pricing.

Important details

  • We highly recommend setting a prompt_cache_key (Responses API; x-grok-conv-id header on Chat Completions). It routes a conversation's requests to the same server, making cache hits reliable; without it you often pay full input price on a cache-cold server. See What Breaks Caching for common mistakes.
  • Long agent loops additionally benefit from context compaction; for tool-heavy workloads see function calling.
  • Encrypted reasoning is always returned on the Responses API. POST /v1/responses responses from grok-4.7 include reasoning.encrypted_content even when include does not list it, so multi-turn conversations keep the model's reasoning without extra configuration. Pass the reasoning items back unchanged in the next request's input; see Encrypted reasoning content. Chat Completions is unchanged.

Fast variant

Grok 4.7 Fast is the same model served on faster infrastructure, billed at twice the standard token rates. It is available only in Cursor and Grok Build, and it is not included in Grok Build's free tier. It is not available on the public xAI API. Rates are on the Pricing page.

Where it runs

  • xAI API: get a key from the console
  • US regional endpoint: also served at https://us.api.x.ai/v1, which keeps inference in the United States, with token usage priced at a 10% premium; see Regional Endpoints
  • Grok Build: the default model of the coding agent
  • Cursor: available on all plans
  • Model gateways: OpenRouter, Vercel, and Cloudflare

Learn more

  • Reasoning - controlling reasoning_effort, including "xhigh"
  • Announcement - launch post with demos and full benchmark figures
  • Models - compare available models and their capabilities
  • Pricing - token pricing for all models

Last updated: September 21, 2026