Learning resourcesReviewed · xAI

xAI Collections Search Tool (Grok) documentation

This is xAI's developer documentation page for the Collections Search tool, which lets Grok models search documents you have uploaded. It is for developers building document question-answering or RAG apps on the xAI API, and its main catch is that the page gives no pricing, usage limits, data-handling terms or licence, and it needs an xAI API key and a pre-built collection. It names the tool collections_search in the xAI SDK and file_search in the OpenAI-compatible Responses API. It walks through an end-to-end example that uploads two Tesla SEC filings, searches them and returns cited answers, and shows how to combine collection search with web search, X search and code execution.

Researched 15 Nov 2026

In short.

This page is xAI's developer documentation for the Collections Search tool, which lets Grok models search documents you have uploaded. It is for developers building document question-answering or retrieval-augmented generation apps on the xAI API, and its main catch is that it says nothing about pricing, limits, data handling or licence, so those must be checked elsewhere. Technically, the page describes a server-side tool that the model calls on its own, possibly many times, to search one or more collections. It is exposed as collections_search in the xAI Python SDK and as file_search in the OpenAI Responses API format. The main example creates a collection, uploads two Tesla SEC filings, waits for processing, and asks an analytical question. The example enables code execution as an optional calculation tool; its sample output shows 13 collection searches but does not establish that code execution occurred or was required. The sample output returns citations as collections:// addresses. Nothing here was run or tested; every behaviour described is what the page states.

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

Coverage is the single selected documentation page at [https://docs.x.ai/developers/tools/collections-search.md], read in full. Linked pages, including the Collections documentation referenced on the page, are excluded and were not reviewed. The capture contains no licence file or separate notice, so reuse terms are unknown. Nothing described was executed: no API calls, no SDK installs, no code runs and no checks of the sample output figures. Statements about behaviour, cost, limits and data handling are limited to what the page says, and anything it does not say is marked unknown.

The overview

What this resource is

This is a single documentation page in xAI's developer documentation, titled Collections Search Tool, at [https://docs.x.ai/developers/tools/collections-search.md]. It is not software you install. It is a guide to a hosted feature of the xAI API that lets Grok search through knowledge bases, called collections, that you have uploaded.

The page names the tool differently by interface: collections_search in the xAI SDK, and file_search in the OpenAI Responses API format. It also says the tool works in all Responses API compatible SDKs. The page does not list an author, a version or a publication date.

Overall assessment

As a quick-start the page is solid. It gives the tool names, five forms of example code, one complete workflow from creating a collection to reading citations, sample console output, an explanation of the citation address format, and a pattern for mixing in web and X search. A developer who already has an xAI API key could use it to build a first prototype.

As a basis for a production decision it is incomplete. It does not state prices, size or file-count limits, the list of supported file types beyond PDFs, text files and CSVs, how retrieval is done internally, or what happens to uploaded data. Some of the page's own claims also go beyond what its sample output shows (see limitations). Nothing was executed for this report, so how well the tool performs is unknown.

Who it is for

The page targets developers who want Grok to answer questions from their own documents. It lists enterprise knowledge bases, financial analysis of filings and earnings reports, customer-support bots grounded in product documentation, research and due-diligence synthesis, compliance and legal work, and personal knowledge management.

Beginners will find the idea clear (upload documents, then let the model search them), but the code assumes comfort with API keys, environment variables, asynchronous Python and JSON requests. The page says a collection can be created in the xAI console [https://console.x.ai] or through the xAI SDK, so some setup does not need code. It is not aimed at people who want a finished chat app.

What it can do

The page lists five key capabilities: retrieving information from uploaded files and collections, semantic search based on meaning rather than only keywords, integrating your own data with Grok's reasoning, powering retrieval-augmented generation workflows, and searching PDFs, text files, CSVs and other supported formats.

In the examples the model works agentically. It chooses its own search queries and result limits, repeats searches with refined wording, and can be given a code execution tool for calculations. It can be combined with web_search and x_search so one answer draws on both your documents and outside sources. Responses carry citations: collections:// addresses for your documents and https:// addresses for web sources.

Using it

What you need

The JavaScript AI SDK, OpenAI Python SDK, Python requests and curl examples all read an XAI_API_KEY environment variable and explicitly point at the xAI API. The first two set the base address [https://api.x.ai/v1], and the requests and curl examples send their request to [https://api.x.ai/v1/responses]. The native xAI SDK end-to-end example also reads XAI_API_KEY and passes a separate XAI_MANAGEMENT_API_KEY when creating its client, which it then uses to create the collection and upload the documents. It does not specify an API endpoint. The hybrid web and X search example receives an already-created client and a model name as function arguments, so it shows no key, endpoint or model of its own.

The OpenAI Python SDK, requests and curl examples note that a collection must already exist. The OpenAI Python SDK example says to create it and upload documents in the xAI console [https://console.x.ai] or with the xAI SDK. The JavaScript example just uses a placeholder vector store ID.

Software named in the examples: the xai_sdk Python package with httpx for downloads, the OpenAI Python SDK pointed at xAI, the requests library, curl, and the JavaScript packages @ai-sdk/openai and ai. The JavaScript, OpenAI Python SDK, requests, curl and native xAI SDK end-to-end examples hard-code the model name grok-4.7. The hybrid example takes the model as a parameter instead. SDK versions, account tiers, regional availability and any access approval are not stated. Beyond the need for a pre-created collection, the page also does not say whether the management key is needed on the OpenAI-compatible path.

How it works

You attach the tool to a model request and give it one or more collection IDs. In the xAI SDK this is collections_search(collection_ids=[...]). In the Responses API format it is a tool of type file_search with vector_store_ids and max_num_results. In the JavaScript AI SDK example (packages ai and @ai-sdk/openai) it is openai.tools.fileSearch with vectorStoreIds and maxNumResults.

The page describes the model deciding when to search. The sample output shows tool calls with arguments such as a query string and a limit, issued repeatedly as the model refines its question. The page's usage output counts these as server-side tool calls (13 searches in the main example), which indicates the searches run on xAI's side rather than in your code. How documents are split, embedded, indexed and ranked is not described. The page only says the search is semantic.

Document upload is asynchronous. The example polls the document status every 3 seconds until it reaches DOCUMENT_STATUS_PROCESSED, and only then asks questions.

Setup steps

Following the page, the order is: get an xAI API key (and a management key if you use the xAI SDK to manage collections); create a collection; upload documents; wait until each document is processed; then make a model request with the collections search tool attached and read the response and its citations. Placeholders such as your_collection_id_here and your-vector-store-id must be replaced with a real collection ID.

One possible problem in the captured text: the curl command shows a doubled backslash at the end of each continued line. If the live page really renders it that way, a shell may not treat those line ends as continuations, so the command might not run as written. Check the rendered docs page before copying it.

A separate point: several Python print statements in the xAI SDK examples also contain doubled backslashes, before the letter n (for example in the Calling tool and Citations lines) and before r (in the Thinking line). This is valid Python. It prints the literal backslash sequences instead of a new line or carriage return, which changes only how the progress output looks and does not by itself stop the code from running. None of the snippets were executed, so whether any of them run as written is unverified.

Worked example on the page

The main example analyses two Tesla filings, a 10-Q and a 10-K, downloaded from Tesla's investor relations site. It creates a collection named tesla-sec-filings, uploads both PDFs concurrently, waits for processing, then starts a chat with collections_search and code_execution enabled. The question is how many consumer vehicles Tesla produced in 2024 and 2025, with working and sources shown. The code streams reasoning progress, prints tool calls, and finally prints citations, token usage and server-side tool usage.

The page's sample output shows 13 collections_search calls, an answer that sums 2024 production (1,773,443) and 2025 production through the third quarter (about 1,220,000), and two citations in the collections://collection_id/files/file_id format. These figures are the page's sample output. They were not checked or reproduced for this report.

Assessment & evidence

Limitations and cautions

Missing information: no upload size or file-count limits, no full list of supported formats, no retrieval or ranking details, no accuracy figures, no latency data, no pricing, no rate limits, and no privacy or retention terms.

Points where the page's claims and its sample output do not fully line up: the page says all information is grounded in the uploaded documents, but the sample answer says its 2024 figures were aggregated from SEC filings and press releases referenced in the collections, which leaves unclear how much came from the documents themselves. The uploaded files are named tesla-10-Q-2024.pdf and tesla-10-K-2024.pdf although the 10-Q address in the code is for the period ended 30 September 2025. The page also reads the high cached-token count as evidence of efficient context reuse, which is an interpretation rather than a measured result. Treat the sample answer as an illustration, and verify citations against your own documents.

The agentic design means the number of searches and tokens varies from run to run, and the model decides what to search for. Answers are only as good as the retrieved passages.

Why this assessment

The page is a primary source from xAI's own documentation domain and covers the feature end to end with concrete code, which makes it a useful learning resource for this tool. Its OpenAI-compatible file_search form means the request shape is reusable for developers who already work with the Responses API.

The assessment stays cautious because the page is promotional in places, such as describing the tool as particularly powerful, and because key decision details (cost, limits, data handling, retrieval quality) are absent. No claim about real-world performance is made, since nothing was run.

Alternatives

The page does not compare itself with anything. Its own table shows that the tool follows the OpenAI Responses API file_search shape, so developers already using that style of hosted file search will find it familiar. This page evaluates no competing services or self-managed retrieval approaches; their comparative capabilities, costs and maintenance requirements are unknown from this evidence.

Evidence base

This report rests on one captured document: the full text of the documentation page at [https://docs.x.ai/developers/tools/collections-search.md] (evidence_4e022796-4661-4135-80fa-5b18b4c291c6). All statements about tool names, parameters, examples, sample output and citation format come from that page. No code was run, no API calls were made, and no outside sources were consulted, so behaviour, accuracy, performance and cost are not independently verified.

Access & freshness

Costs

The page states no prices. It does not say how collection storage, document processing, collections search calls, web or X search calls, or code execution are billed, and it does not mention free tiers or rate limits. Cost is therefore unknown from this evidence.

The sample usage output gives a sense of scale only: 383,265 prompt tokens (177,518 of them cached), 3,352 reasoning tokens, 1,306 completion tokens and 13 server-side collections search calls for one question over two filings. Without pricing the page does not let you turn this into money, and search-heavy agentic runs may use many tokens.

Rights and terms

The page carries no licence or reuse statement for its text or code samples. Terms for using the xAI API, including ownership of uploaded documents, retention, whether data is used for training, and confidentiality, are not covered here and are unknown from this evidence.

The example downloads public Tesla filings from the company's investor relations site. The page does not discuss rights or permissions for the documents you upload. Anyone planning to upload confidential, regulated or third-party material should read xAI's terms and data policies separately.

Freshness

The page was captured on 15 November 2026 and shows no publication or last-updated date. The sample output mentions that fourth-quarter 2025 data was not available as of 13 November 2025, which suggests the example was written around then, about a year before capture. The end-to-end examples hard-code the model name grok-4.7. Whether that is the current recommended model, and whether parameter names, SDK helpers or behaviour have changed since, is unknown. Check the live documentation before relying on the snippets.

Suggested next steps

If you are considering this tool, first look up xAI's current pricing, rate limits, file limits and data-handling terms, since the page does not give them. Then try it on a small, non-sensitive collection, wait for every document to reach the processed status before querying, and compare the cited sources with the answers it gives.

When copying the code, replace the placeholder collection IDs and set your own API keys as environment variables. Check the rendered docs page for the curl line continuations, because the captured curl command shows doubled backslashes at line ends that a shell may not treat as continuations. The doubled backslashes in the Python print strings are valid Python and only make the progress output show literal backslash sequences instead of line breaks. Change them to single backslashes if you want real line breaks. Whether the snippets run as written is unverified. If you will combine collection search with web or X search, remember that citations may then come from public sources as well as your own files.

Evidence for this report

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