In short.
The xAI Files guide helps developers add document questions and summaries to Grok applications, but automatic searches incur charges alongside token usage. It explains how attachments activate server-side retrieval and provides JavaScript HTTP and Python SDK examples. The documented limits include 512 MB per file, agentic-model compatibility and no batch mode with n > 1. The examples were not executed; answer quality, latency, numerical costs and data-handling terms remain unassessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete supplied page at [https://docs.x.ai/developers/files.md], including retrieval behavior, token accounting, pricing mechanics, setup, both code examples, capabilities and limitations. Linked API references, pricing tables, Collections documentation and detailed file guides are excluded. No separate license or rights notice appears in the supplied text. No code was executed and no API requests were made; functionality, answer quality, latency, deletion behavior and actual charges remain unverified.
The overview
Identity
This is xAI's developer documentation for attaching files to Grok conversations, available at [https://docs.x.ai/developers/files.md]. It teaches an API feature rather than providing a standalone application or downloadable library.
Files supply immediate document context for conversations. The page distinguishes them from Collections, which it describes as persistent document storage with semantic search across many documents.
Assessment
The guide is useful for developers who want document-aware conversations without building the retrieval process themselves. Its practical strength is showing how public URLs and uploaded files enter the same chat workflow.
It provides enough detail to understand an initial integration, but not to predict answer reliability or operating cost. Because Grok chooses its searches automatically, a single user question can produce multiple billable search invocations.
Users
The intended audience is developers building applications that summarize documents, extract information or answer questions across attached files. Beginners receive a complete upload, question and deletion example; experienced developers receive request fields and an explanation of server-side retrieval.
The page is less sufficient for teams choosing a persistent knowledge store or requiring detailed retrieval controls, measured accuracy or data-governance guarantees. Those details are not established here.
Capabilities
The page documents public-URL attachments, private-file uploads referenced by ID, searches across multiple attached documents and follow-up questions without reattaching files. Grok can extract information and combine findings into an answer.
Streaming can expose notifications when document searches occur. The page also describes combining files with a separate code execution tool for Python-based analysis, statistics and transformations, but the supplied examples do not demonstrate that combination.
Using it
Requirements
The examples require an xAI API key, an accessible public file URL or an uploaded file ID, and a Grok model supporting agentic tool calling. Both examples use grok-4.7; the limitations also list grok-4.20, grok-4.5 and grok-4.6 as examples.
The JavaScript example uses fetch, FormData and Blob. The Python example uses xai_sdk. Minimum runtime and SDK versions are unspecified. Each file must fit the documented 512 MB maximum.
Mechanism
Attaching a file implicitly activates the server-side attachment_search tool. Grok interprets the question, chooses searches, retrieves relevant document passages and synthesizes an answer. The page describes this as an agentic workflow: the model decides which searches to perform and may search repeatedly.
Retrieved document content does not directly appear in message history. The page describes token usage across prompts, internal processing, reasoning and final answers, and says repeated document content can benefit from prompt caching. It supplies no measured token savings.
Setup
Supply XAI_API_KEY through the environment used by the example. For a public document, provide its URL. For a private upload, the HTTP example sends multipart form data to [https://api.x.ai/v1/files], including the file and purpose set to assistants, then takes the returned file ID.
Attach the URL or ID to a user message and submit the question. The examples finish by deleting the uploaded file. More detailed file-management and chat instructions are linked from the page, but their contents are outside this evidence.
Example
The JavaScript example asks Grok to summarize two documents: a public text file and a newly uploaded employee text file. It posts to [https://api.x.ai/v1/responses] with model set to grok-4.7. The user message contains input_text and two input_file entries, using file_url for one attachment and file_id for the other.
The Python equivalent uses client.files.upload, client.chat.create, the user and file helpers, chat.sample and client.files.delete. Neither example includes an observed answer or billing result. Nothing was executed.
Assessment & evidence
Limitations
The documented maximum is 512 MB per file. Document search requires models supporting agentic tool calling, and the page says these requests do not support batch mode with n > 1.
Listed formats include TXT, Markdown, code files, CSV, JSON and PDF, plus unspecified other text-based formats. Support for scanned PDFs, image interpretation, password-protected files and exact table extraction is not established. Maximum attachment count, parsing limits, retrieval completeness and latency are also unspecified.
Reasoning
The documented design suggests a good fit for applications where developers want Grok to handle search decisions over documents attached to a conversation. That fit follows from automatic attachment_search activation and the examples' small amount of integration code.
Automatic retrieval does not establish exhaustive document coverage or correct answers. The page describes intended behavior but supplies no accuracy evaluation, comparison against manual review or demonstrated source-citation behavior.
Alternatives
Collections is the alternative explicitly identified on this page for persistent document storage and semantic search across many documents. That distinction can guide which documentation to consult when the intended application needs a lasting document repository.
The Collections implementation, pricing and limitations are not assessed because its linked page is excluded. No competing services or independently managed retrieval systems are compared in the supplied evidence.
Evidence
The evidence is the complete selected xAI documentation page at [https://docs.x.ai/developers/files.md], captured at 2026-11-15T05:45:51.374Z. Its source revision is sha256:19da60bcccf156f5bf1e5184c0f9316b6f17de6fbce5a3755485359f6c6dca80.
This first-party documentation supports descriptions of the API workflow, example requests and stated limits. It contains no execution receipts, measured retrieval results, latency measurements or observed charges.
Access & freshness
Costs
Document search is billed per tool invocation in addition to standard token charges. Each search counts separately, so the documented possibility of repeated searches means one question does not necessarily equal one search charge.
Numerical tool and model rates are absent. The page links to [https://docs.x.ai/developers/pricing#tools-pricing], but that linked pricing table is outside scope. Total request cost, any storage charges and the financial effect of caching are unknown from this page.
Rights
The supplied page does not state a license for redistributing its text or example code, or establish rights to reuse the linked example documents.
It also does not specify uploaded-data ownership terms, retention periods, training use, data residency or access-control guarantees. Describing uploads as private does not resolve those contractual and operational questions.
Freshness
The capture establishes what this documentation stated on 15 November 2026. The page provides no explicit publication date, last-updated date or SDK version.
The named models and request structures belong to that captured source version. Their availability and behavior after capture have not been verified.
Actions
For an initial evaluation, use a small document with known answers and compare Grok's responses against the original text, including a follow-up question and a question spanning two attachments. Observe search invocations and token usage to estimate cost from actual usage. These are suggested evaluations, not completed tests.
Before adoption, confirm numerical prices, model availability and the data-handling terms needed for the intended documents. Consult the linked file-management guide at [https://docs.x.ai/developers/files/managing-files] and chat guide at [https://docs.x.ai/developers/model-capabilities/files/chat-with-files]; neither linked page was assessed here.
