In short.
This xAI guide helps developers add X search to Grok applications, with extra retrieval charges and account and date filters that do not constrain thread retrieval. It explains keyword, semantic and user search, thread fetching, optional media understanding and per-request usage counts. The examples use grok-4.7 through the Responses API or Vercel AI SDK. Nothing was executed; search quality, latency and actual request costs were not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete selected documentation page at [https://docs.x.ai/developers/tools/x-search.md], including SDK examples, parameters, retrieval functions, media options, billing, usage counts and citation references. Linked pricing, tool-usage-details and citations pages are excluded, so their additional rules and notices are unknown. No separate library files were supplied. No installation, API request, retrieval, citation handling, media analysis or billing behavior was executed or tested.
The overview
identity
This is xAI's documentation for X Search, a tool that lets Grok retrieve and analyze content from X. The page is available at [https://docs.x.ai/developers/tools/x-search.md].
The guide documents x_search for the Responses API and xai.tools.xSearch() for the Vercel AI SDK. It is an integration reference with examples, rather than a downloadable model or dataset.
assessment
The guide is useful for understanding how to connect Grok to X content and account for retrieval charges. Its strongest details are the distinction between search and thread behavior, exact date boundaries and fetch counts that include repeated results.
A significant catch is that account and date filters apply to keyword and semantic searches but not thread fetches. The documentation therefore does not support treating those filters as a guarantee that every retrieved post stays within the requested accounts or dates. Reliability and answer quality were not assessed.
users
The guide suits developers building assistants that summarize X discussions, follow named accounts, investigate reactions during a date range or retrieve conversation context. These are potential applications of the documented functions, not demonstrated outcomes.
Beginners get Python, JavaScript and HTTP examples. Experienced developers get parameter limits, response item names, streaming usage locations and billing fields. Readers still need basic familiarity with API requests, credentials and response objects.
capabilities
X Search supports keyword search with X's advanced search operators, semantic search by meaning, user search by name or description, and thread retrieval covering a post with its parents and replies. Keyword results can be sorted by Top or Latest.
Search controls include allowed or excluded account handles and date ranges. Optional image and video understanding lets the model examine media in retrieved posts; both options default to false. The page describes cited answers and says video understanding is available for X Search but not Web Search.
Using it
requirements
The examples require an xAI API key, supplied through XAI_API_KEY, and a client able to call the Responses API. Supported routes shown are the OpenAI Python SDK configured for xAI, the Vercel AI SDK using @ai-sdk/xai and ai, and direct HTTP requests.
The examples use grok-4.7. The page does not establish the full compatible-model list, minimum SDK versions, account eligibility, rate limits or required spending limits.
mechanism
Adding x_search to the request's tools makes retrieval functions available to the model. The model chooses which functions to call and how often, reads fetched posts and produces an answer with citations.
The underlying functions are x_keyword_search, x_semantic_search, x_user_search and x_thread_fetch. Each invocation appears as a custom_tool_call response item named after the function. Post retrieval and profile retrieval have separate usage counts.
Handle and date parameters apply to every keyword and semantic search, including queries the model writes itself. Thread fetches do not use those parameters. The page does not describe equivalent filtering behavior for user search.
setup
For the Python route, configure an OpenAI client with the xAI API key and base_url [https://api.x.ai/v1]. Call client.responses.create with a model, input and a tools entry whose type is x_search. Direct HTTP requests use [https://api.x.ai/v1/responses].
For Vercel, use xai.responses('grok-4.7') with generateText and register xai.tools.xSearch(). Vercel options use camelCase names such as allowedXHandles and fromDate; API examples use allowed_x_handles and from_date.
Handle lists omit the @ symbol. Allowed and excluded lists cannot be combined in one request. The documented limit is 20 handles, reduced to 10 in the Vercel AI SDK. Dates must use YYYY-MM-DD; full date-times and other formats are not applied.
example
The guide illustrates asking what SpaceX posted about Starship in September 2026. Its Python request uses model grok-4.7, allowed_x_handles set to ["SpaceX"], from_date set to 2026-09-01, to_date set to 2026-10-01 and extra_body containing max_turns set to 2.
The date interval begins at 00:00 UTC on September 1 and excludes October 1. The example then reads x_posts_fetched and x_users_fetched from usage.server_side_tool_usage_details. The page shows an abridged result of 19 posts and zero profiles; this is documentation output, not a result reproduced here, and future results can differ.
Assessment & evidence
limitations
Retrieval is model-directed: the model chooses queries and call frequency, and the page warns that example results vary. It provides no measured accuracy, completeness, latency or reproducibility guarantees.
Account and date filters do not constrain fetched threads. The end date is exclusive, and incorrectly formatted dates are not applied. These details matter when a task requires a strict account list or reporting period.
The page does not establish historical coverage, access to restricted content, citation completeness or media-analysis accuracy. Those capabilities remain unknown, and no API behavior was tested.
reasoning
The documented design is a plausible fit for applications that need cited answers informed by X discussions and can accommodate model-selected retrieval. Fetch counters provide a concrete basis for accounting after a request, while account and date controls can focus the initial searches.
A requirement that every retrieved item obey the same account and date restrictions is not supported by the documented thread behavior. Similarly, the presence of citations does not by itself establish answer accuracy. These are conclusions drawn from the described mechanism, not measured findings.
alternatives
The page offers alternative integration routes to the same capability: the Responses API through a compatible SDK, direct HTTP or the Vercel AI SDK. The documented handle-list limit differs between the API and Vercel routes.
Web Search is mentioned only in relation to video understanding. The supplied evidence does not support a broader comparison with Web Search, direct X APIs or other providers on coverage, quality, pricing or speed.
evidence
The evidence is the complete xAI documentation page at [https://docs.x.ai/developers/tools/x-search.md], captured as selected-page.txt on 2026-11-15T04:13:46.135Z. Its source revision is sha256:f4fe7f828dda626dd9dadc8adf7d2c2b959729cfc7da91c87fb57afd8864688a.
This is first-party documentation containing examples and abridged outputs. It supports statements about the documented interface and billing model, but provides no independent performance measurements. No code or API request was executed, and no displayed output was independently reproduced.
Access & freshness
costs
The page lists $5 per 1,000 posts fetched and $10 per 1,000 user profiles fetched, in addition to model token charges. Image and video understanding are billed as image tokens. Token rates and the complete billing rules on the linked pricing page are not supplied.
Post counts include parent and quoted posts and every post in a fetched thread. Counts accumulate across calls without deduplication, so retrieving the same post twice counts twice. These rates therefore cannot be converted into a fixed price per question from this page alone.
The guide recommends narrowing accounts and dates, reducing search rounds with max_turns or Vercel's maxTurns, and inspecting fetch counts. These controls do not establish a hard monetary ceiling. For streaming responses, total usage appears on response.completed or, for a truncated response, response.incomplete.
rights
The supplied page does not state a license for its documentation or code examples. It also does not establish permission to store, redistribute or commercially republish retrieved X posts, profiles or media.
Data retention, privacy terms and content-use restrictions are not described. Citation support alone does not establish reuse rights; those permissions remain unknown from this page.
freshness
The capture is dated November 15, 2026. The page ties its usage-count discussion to per-item pricing in effect as of September 21, 2026 and uses grok-4.7 in its examples.
No publication date, revision history or SDK package versions are provided. The capture date does not establish when each detail was last updated, and subsequent pricing or compatibility changes are unknown.
actions
Choose the Python, Vercel or HTTP example that matches the application. Define the intended accounts and UTC date interval, observe the handle limits and exclusive end date, and account for the fact that thread retrieval does not follow those filters.
For an initial implementation, inspect function-call items, citations and both fetch counters alongside the generated answer. The guide recommends limiting search rounds to reduce retrieval, but actual spending still depends on fetched content and tokens.
Before relying on the integration, confirm current model access, SDK compatibility and full pricing at [https://docs.x.ai/developers/pricing#tool-invocation-costs]. Consult [https://docs.x.ai/developers/tools/citations] for citation handling. Those linked pages are referenced by the guide; their contents are not included in this report's evidence.
