AI & Agents

Grok Context Window: Token Limits, Architecture, and Large File Handling

The Grok context window spans from 256,000 tokens on grok-build-0.1 up to 1,000,000 tokens on Grok 4.3 and the Grok 4.20 variants, with the Grok 4.5, 4.6, and 4.7 flagships at 500,000. Raw capacity is only half the story, because xAI doubles both input and output rates once a prompt reaches 200,000 tokens. Understanding token consumption, pricing thresholds, and external workspace retrieval through MCP enables teams to process large document collections without hitting memory walls.

Derek Labian 13 min read Updated
Grok context windows range from 256,000 tokens on grok-build-0.1 to 1,000,000 tokens on Grok 4.3 and the Grok 4.20 variants.

What Is the Grok Context Window and Token Limit?

The Grok context window ranges from 256,000 tokens on grok-build-0.1 up to 1,000,000 tokens on Grok 4.3 and the Grok 4.20 variants, defining the maximum volume of text, code, and reasoning steps xAI models can process in a single request. The Grok context window is the maximum number of tokens that an xAI model can process in a single conversation turn across input context and output generation.

In natural language processing, a token represents a fragment of text roughly equivalent to three-quarters of an English word or four characters of source code. On the 256,000 token grok-build-0.1, that translates to approximately 192,000 words or roughly 600 pages of standard single-spaced text. The flagship Grok 4.5, 4.6, and 4.7 models carry a 500,000 token ceiling, expanding processing capacity to approximately 375,000 words or 1,500 pages. At the top of the range, Grok 4.3 and the Grok 4.20 checkpoints provide a 1,000,000 token context window, accommodating extensive documentation, complex code repositories, or historical conversation logs.

Headline context figures also obscure a second boundary that matters more in practice: cost. Every model xAI publishes is billed at one rate below 200,000 prompt tokens and at double that rate at or above it, so the last 800,000 tokens of a Grok 4.3 window are never as cheap as the first 200,000.

For automated pipelines and software developers, xAI provides direct programmatic access through the xAI API at https://api.x.ai/v1. The API exposes the full technical context window of each specific model checkpoint. Choosing the right model requires balancing token volume against inference latency and operational cost.

The table below compares the context windows and published text API pricing across every Grok text model xAI documents as of September 2026. Input and output prices are per million tokens, quoted at the rate that applies below the 200,000 token threshold:

Model Context Window Input / 1M Output / 1M Verified Date
grok-4.7 500,000 tokens $2.00 $6.00 2026-09-22
grok-4.6 500,000 tokens $2.00 $6.00 2026-09-22
grok-4.5 500,000 tokens $2.00 $6.00 2026-09-22
grok-4.3 1,000,000 tokens $1.25 $2.50 2026-09-22
grok-4.20-0309-reasoning 1,000,000 tokens $1.25 $2.50 2026-09-22
grok-4.20-0309-non-reasoning 1,000,000 tokens $1.25 $2.50 2026-09-22
grok-4.20-multi-agent-0309 1,000,000 tokens $1.25 $2.50 2026-09-22
grok-build-0.1 256,000 tokens $1.00 $2.00 2026-09-22

As the comparison reveals, model capability and context capacity do not follow a simple linear path. The flagship Grok 4.7, 4.6, and 4.5 models feature a 500,000 token context window tailored for precision tool use and low-latency reasoning, and they are the most expensive per token. The wider 1,000,000 token window belongs to Grok 4.3 and the Grok 4.20 checkpoints, which cost less per token and suit large text ingestion rather than the newest reasoning work.

How xAI Architecture and Token Pricing Scale with Context

Understanding the internal mechanics of the xAI context window is essential for building stable applications. A context window is not a scratchpad for boundless data storage. It is an active memory buffer that must accommodate system prompts, retrieved tool definitions, multi-turn conversation history, and the model's generated output tokens.

Every conversation turn consumes a portion of the total token budget. When an agent invokes external tools or receives structured schema definitions, those specifications consume input tokens before the user submits a single query. In models supporting internal reasoning steps, such as Grok 4.7, the model generates internal thinking tokens during complex problem decomposition. Although these thinking tokens allow the model to verify its logic, they consume space within the total context allocation.

Also, API costs scale dramatically as context size expands. xAI applies a tiered pricing structure based on prompt token volume across its entire text model line. Standard pricing applies to requests below 200,000 prompt tokens, and both input and output rates double for the entire request once prompt volume reaches that threshold. A single analytical query ingesting a 400,000 token repository can cost twice as much per token as two separate queries kept within the base tier.

Beyond financial costs, expanding the context window introduces technical performance degradations known as context rot and needle-in-a-haystack retrieval dropoff:

  1. Attention Dispersion. As the prompt length approaches 500,000 or 1,000,000 tokens, self-attention mechanisms distribute probability weights across thousands of competing passages. Models frequently miss fine-grained instructions placed in the middle of long inputs.

  2. Time to First Token (TTFT). Processing hundreds of thousands of input tokens requires substantial prefill computation on GPU clusters. In interactive chat applications, large prompts cause perceptible latency delays before streaming begins.

  3. Compounding Hallucinations. In multi-turn workflows, intermediate tool outputs and erroneous guesses remain inside the context history. The model references its earlier incorrect assumptions in subsequent responses, reinforcing errors across turns.

Because of these constraints, experienced engineers treat large context windows as emergency headroom rather than default file storage.

What Happens When Files Exceed Grok Token Limits?

When interacting with Grok through the web interface or automated API pipelines, users frequently attempt to attach large file collections, including complete code repositories, corporate handbooks, financial balance sheets, and scanned PDF exhibits. Understanding how the system handles file boundaries prevents unexpected pipeline failures.

In the consumer interface on grok.com and X, file uploads are preprocessed before ingestion. When a user uploads a PDF or text document, the browser parses the text content and inserts it directly into the prompt conversation history. xAI does not publish a separate context figure for the chat interfaces, so the practical ceiling is whichever model is serving your session. Even when files fit within that limit, long documents rapidly exhaust the conversation memory, causing Grok to forget initial system instructions or overwrite earlier constraints.

At the API level, attempting to send a prompt larger than a model's declared maxPromptLength results in an immediate HTTP 400 Bad Request error from https://api.x.ai/v1. The API will not automatically summarize or prune your payload; the developer is entirely responsible for truncating text before submission.

Common failure modes when handling large files directly in Grok include:

  • Truncated Code Dependencies. Uploading entire codebases often truncates peripheral utility files and schema definitions, forcing Grok to hallucinate function signatures.

  • High Cost Per Query. Running repetitive queries against an unindexed 300,000 token document archive incurs the doubled token rate on every request, creating unsustainable API billing.

  • Inability to Retain Updates. Once a conversation session resets or reaches its context cap, all uploaded file content is purged from the model's active memory. The user or agent must re-upload the entire corpus on subsequent runs.

  • Loss of Granular Permissions. When files are pasted into an AI prompt, sensitive internal documents mix indiscriminately with general queries, bypassing enterprise access controls and audit logging.

To bypass these limitations, modern AI architectures decouple long-term file storage from the model's transient context window.

Fastio features

Scale your agent file memory beyond context limits

Establish shared workspaces where AI agents search documents via remote MCP tools and hybrid semantic retrieval. Every organization starts with a 14-day free trial.

Connecting Grok to Fast.io for Large Corpus Handling via MCP

Rather than forcing a massive document corpus into Grok's transient context window, engineering teams use external intelligent storage to supply relevant context on demand. Fast.io provides shared, organization-owned workspaces specifically designed for human and agent collaboration.

In this architecture, your file corpus lives in a persistent Fast.io workspace. You can upload files directly or import them from existing cloud repositories such as Dropbox, Box, OneDrive, or Google Drive without local file transfer. Once files arrive in a workspace, Fast.io automatically indexes them using Intelligence Mode. This built-in retrieval engine combines full-text keyword indexing, semantic meaning extraction, and metadata valuation into a unified Hybrid Search layer.

Instead of stuffing 200 megabytes of documentation into Grok's prompt window, an AI agent connects to Fast.io through the Model Context Protocol (MCP). Fast.io provides a remote MCP server hosted at https://mcp.fast.io/mcp over Streamable HTTP, with legacy Server-Sent Events supported at https://mcp.fast.io/sse. Agents authenticate using standard workspace credentials or API keys at https://mcp.fast.io/mcp/key.

Below is an example MCP client configuration connecting an agent to a Fast.io workspace:

{
  "mcpServers": {
    "fastio": {
      "url": "https://mcp.fast.io/mcp/key",
      "headers": {
        "Authorization": "Bearer YOUR_FASTIO_API_KEY"
      }
    }
  }
}

When an agent needs information to answer a user prompt or execute a code modification, it invokes the consolidated storage tool using the search action:

{
  "method": "tools/call",
  "params": {
    "name": "storage",
    "arguments": {
      "action": "search",
      "query": "authentication session expiration rules",
      "workspace_id": "ws_enterprise_kb"
    }
  }
}

Fast.io searches the indexed workspace and returns only the precise paragraphs and citations relevant to the query. The agent injects a lean 1,500 token snippet into Grok's context window instead of consuming 300,000 tokens of raw file data. This targeted retrieval delivers several operational advantages:

  • Zero Token Inflation. Grok processes only the relevant excerpt, keeping token consumption low and staying well below the 200,000 token pricing threshold.

  • Strict Audit Logging. Every file read, modification, and agent query is recorded in an immutable, append-only audit log, ensuring team visibility into agent actions.

  • Multi-Agent Coordination. Multiple autonomous agents and human team members can access, update, and search the same shared workspace simultaneously without file lock conflicts.

  • Full Version History. Fast.io maintains complete per-file version history. If an agent writes an incorrect code modification, developers can instantly roll back to previous revisions.

  • Agent-to-Human Handoff. An autonomous agent can establish a workspace, ingest client documents, organize project folders, and initiate an ownership transfer to hand control back to a human administrator.

Every organization starts with a 14-day free trial, which requires a credit card. Subscription plans scale smoothly across Starter, Business, and Enterprise tiers for teams. To configure persistent storage for your AI agents, review the intelligent workspaces overview and review plan options on the Fast.io pricing page.

Building production-grade systems with Grok requires disciplined context hygiene. Implementing structured ingestion patterns protects your application from latency spikes, unexpected bills, and model degradation.

Developers should adopt the following technical strategies when designing workflows around Grok:

1. Enable Prompt Caching on Repeated System Instructions

The xAI API provides prompt caching for repeated prefix content. When an application submits identical system prompts, tool definitions, and baseline reference data across multiple requests, xAI reuses cached key-value states. Cached prompt tokens are billed at a fraction of standard input rates, lowering overhead for multi-turn agent loops. Keep system prompts and static tool declarations at the beginning of the prompt array to maximize cache hit rates.

2. Implement Dynamic Context Compaction

In extended chat sessions, conversation histories inevitably accumulate conversational noise, tool execution errors, and repetitive summaries. Before forwarding the full message history to Grok, run a compaction routine that summarizes earlier turns and strips redundant tool responses. Retain only recent user inputs, critical system instructions, and active task state.

3. Use Structured Document Extraction with Metadata Views

For document-heavy workflows such as legal contract analysis, financial accounting, and compliance review, full-text ingestion is rarely the most efficient pattern. Fast.io offers Metadata Views, which turn unstructured documents into live, queryable databases.

Users describe the fields they need extracted in plain English, and the platform automatically populates a typed schema across PDFs, spreadsheets, Word documents, and images. Instead of reading an entire 80-page lease agreement into Grok to locate a renewal date, an agent queries the structured Metadata View via MCP and retrieves typed fields in milliseconds.

4. Separate Working Context from Reference Knowledge

Reserve Grok's active context window strictly for reasoning, intermediate task state, and final synthesis. Offload reference knowledge, historical archives, and large media assets to an external workspace layer. By combining Fast.io's hybrid search and MCP tools with Grok's high-speed inference, developers achieve infinite effective storage capacity while keeping individual model requests fast, accurate, and cost-effective.

Sources

References used to verify factual claims in this guide.

  1. 1 xAI: Grok Models and Pricing Accessed

    xAI documents Grok 4.3 and the Grok 4.20 checkpoints at a 1,000,000 token context window, the widest it publishes, at $1.25 per million input tokens below the long context threshold. xAI doubles both input and output rates for an entire request once the prompt reaches 200,000 tokens.

Frequently Asked Questions

What is the context window of Grok?

Grok's context window depends on the specific model. xAI documents Grok 4.7, Grok 4.6, and Grok 4.5 at 500,000 tokens, Grok 4.3 and the Grok 4.20 checkpoints at 1,000,000 tokens, and grok-build-0.1 at 256,000 tokens. xAI publishes no separate context figure for the grok.com and X chat interfaces, so the practical ceiling there is whichever model serves the session.

How many tokens can grok-build-0.1 handle?

grok-build-0.1 handles up to 256,000 tokens in a single conversation turn across input context and output generation. This capacity equals approximately 192,000 English words or roughly 600 pages of text. While sufficient for standard interactive chats and moderate code reviews, larger multi-document tasks require the wider Grok 4.3 window or an external retrieval architecture.

What is the token limit on Grok?

The maximum token limit across the Grok model family is 1,000,000 tokens, supported by Grok 4.3 and the Grok 4.20 checkpoints on the xAI API. The newer flagship reasoning models, Grok 4.7, 4.6, and 4.5, operate with a 500,000 token limit, so the widest window and the most capable model are not the same choice.

Can Grok read large PDF files?

Yes, Grok can process text extracted from PDF documents up to its working context limit. However, pasting or uploading extensive multi-hundred-page PDFs directly into consumer chat can exhaust memory and truncate key sections. For reliable processing of large PDF collections, connect an external workspace via MCP to retrieve targeted document excerpts using semantic search.

What happens when an API request reaches the 200,000 token threshold on Grok?

xAI applies long context pricing across its text model line. Once a request's prompt reaches 200,000 tokens, every token in that request is billed at the higher rate, which is double the standard input and output rate. A 400,000 token prompt therefore costs more than twice what two 200,000 token prompts would.

How can teams process document archives larger than Grok's context window?

Teams store large document archives in an external persistent workspace such as Fast.io. The workspace indexes documents using hybrid semantic search and exposes them to Grok through a remote MCP server. The model retrieves only relevant document sections dynamically, keeping active token consumption minimal.

Related Resources

Fastio features

Scale your agent file memory beyond context limits

Establish shared workspaces where AI agents search documents via remote MCP tools and hybrid semantic retrieval. Every organization starts with a 14-day free trial.