Learning resourcesReviewed · xAI

xAI Chat with Files

xAI's Chat with Files is a guide for developers building apps that answer questions about documents, but attachments require a Grok model with server-side tool support. It demonstrates file attachments, streaming, follow-up questions, image inputs and optional Python execution.

Researched 15 Nov 2026

In short.

xAI's Chat with Files is a guide for developers adding document questions and answers to applications, but it leaves prices, file limits and answer accuracy unspecified. Its examples show how to attach public files or uploaded file IDs, search across documents, preserve conversation context and combine files with images or code execution. The guide recommends grok-4.7 and requires models that support server-side tools. Runtime behavior and performance have not been assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete selected page at [https://docs.x.ai/developers/model-capabilities/files/chat-with-files.md], including its examples, model recommendation and limitations. Linked pages, example files, image assets, pricing information and external terms are excluded. No explicit license notice appears in the supplied page. No code or API requests were executed; response quality, compatibility, performance and actual costs remain unassessed.

The overview

identity

Chat with Files is an xAI developer documentation page at [https://docs.x.ai/developers/model-capabilities/files/chat-with-files.md]. It teaches an API capability rather than providing a standalone document-chat application.

The page includes Python, JavaScript and curl examples using the OpenAI SDK, direct HTTP requests and the xAI SDK. The examples use grok-4.7.

assessment

The guide provides a concrete starting point for developers who need document questions and answers inside an application. It covers both a first request and extensions such as streaming, multiple documents and follow-up questions.

Its value is practical request construction. It provides no measured accuracy, latency, reliability or cost results, so it does not establish suitability for a particular production workload.

users

The material suits developers building report assistants, product-documentation helpers or applications that combine information from several documents. Beginners need basic familiarity with API keys, request payloads and Python or JavaScript.

Developers already using the OpenAI SDK can follow examples that configure it for xAI's API endpoint. More experienced developers can inspect the streaming events, conversation-state handling and optional execution tool. The page does not provide a no-code interface or a complete application tutorial.

capabilities

The documented capability accepts a publicly accessible file URL or an uploaded file ID and automatically enables document search. Examples cover one document, several documents in one message, streamed responses and questions across multiple conversation turns.

Files can share a message with an image. For data analysis, developers can explicitly enable code execution so Grok can write and run Python in a sandbox. The page illustrates revenue calculations and regional sales comparisons, without supplying verified calculation results.

Using it

requirements

The examples require an xAI API key, supplied through XAI_API_KEY, and access to xAI's API. File attachments require an agentic-capable model, meaning a model that supports tools executed by the service. The page recommends grok-4.7.

URL attachments must be publicly accessible. Files supplied by ID must first be uploaded through the Files API. The page does not establish account entitlements, minimum SDK versions, a complete compatible-model list or detailed upload requirements.

mechanism

Attaching a file automatically gives the model document-search capabilities. The request becomes an agentic workflow: the model can use server-side tools while answering the question. The page does not describe indexing, chunk selection, OCR support or guarantees that every relevant passage will be retrieved.

The Responses API examples link follow-up turns through previous_response_id. The xAI SDK example enables use_encrypted_content and appends earlier responses to conversation history. The page presents encrypted content as a way to retain context efficiently; it does not establish broader data-security or retention guarantees.

setup

For the OpenAI SDK route, configure the client with the xAI key and base URL [https://api.x.ai/v1]. Create a response containing a user message with an input_text item and an input_file item. Use file_url for a public address or file_id for an uploaded file. Direct HTTP examples post to [https://api.x.ai/v1/responses].

Set stream to true to receive incremental output; the JavaScript example reads response.output_text.delta events. For data analysis, the Responses API example explicitly adds a code_interpreter tool, while the xAI SDK uses code_execution(). Installation commands and dependency versions are absent.

example

The basic example attaches [https://docs.x.ai/assets/api-examples/documents/sales-report.txt] and asks for the report's total revenue. It demonstrates the request structure and extracting answer text; the supplied evidence does not include the document's contents or a resulting revenue figure.

A multiple-document example attaches project timeline, budget and team files, then asks when the project started, its budget and its team size. This illustrates a useful cross-document question, but no answer or accuracy result is supplied.

Assessment & evidence

limitations

The guide states that file attachments with document search do not support batch mode with n greater than 1. It recommends streaming for better visibility into document searching and warns that very long or highly unstructured documents may require more processing.

Maximum file size, attachment count, supported-format coverage, rate limits, scanned-document handling and answer-citation behavior are unspecified. Examples include TXT and CSV files and a PDF URL, but they do not establish comprehensive format support. Answer completeness and calculation correctness remain unassessed.

reasoning

The practical attraction is that the shown requests attach a document and ask a question without separately configuring a document-search tool. This suggests a straightforward starting point for applications that need document lookup through xAI.

The tradeoff is dependence on compatible server-side tools and processing whose cost and retrieval coverage are not quantified here. The examples support evaluating an integration approach, while leaving workload-specific accuracy and economics unknown.

alternatives

Within the guide, developers can choose the OpenAI SDK, direct HTTP requests or the xAI SDK as client routes. Public URLs avoid an upload step for accessible files; uploaded IDs accommodate files that are not public.

The page provides no comparison with other document-question-answering services or locally managed retrieval systems. Relative accuracy, privacy, portability and total cost are unknown.

evidence

The evidence consists of the complete captured xAI documentation page at [https://docs.x.ai/developers/model-capabilities/files/chat-with-files.md]. It supports statements about documented request syntax, examples and stated constraints.

Linked file-management and tool-overview pages, sample documents and image assets are outside the supplied evidence. The examples were not executed, and no observed responses, benchmarks or independent performance results are available.

Access & freshness

costs

Prices and total operating cost are unknown from this page. It gives no token rates, document-search fees, upload or storage charges, or code-execution pricing.

The guide warns that large documents requiring many searches can increase token usage. Its xAI SDK streaming examples display usage information, including reasoning-token counts, but provide no measured consumption or cost estimates.

rights

The selected page supplies no explicit license or redistribution terms for its documentation and sample code. Commercial-use permissions and permission to redistribute captured material are unknown from this evidence.

The uploaded-file option accommodates documents that are not publicly accessible, but the page does not establish retention, deletion, training-use or confidentiality terms. A file ID describes an access method; it does not establish those protections or rights over the document.

freshness

The page was captured on 15 November 2026 at 11:00:06.751 UTC. Its source revision is SHA-256 45586fe77c514f811d04e9f0ee7e6a77a03b82435391986976c8eeac2c058748.

The captured text recommends grok-4.7 but supplies no publication date, update date or SDK package versions. Availability and compatibility beyond the captured documentation are unverified.

actions

For an initial evaluation, choose a small document with answers you can check, select the URL or uploaded-ID route, and reproduce a single-question example. Use streaming to observe progress and inspect reported usage. Add multiple files or follow-up turns as the application requires.

Before adoption, establish current prices, model availability, file limits, supported formats and document-handling terms. Check representative answers and calculations against the original documents, especially for long files and questions spanning several sources.

Evidence for this report

selected-page.txtselected · checked 2026-11-15