X Search tool schema for fetching X posts and profiles

Example API call structure for the X Search tool, including parameters for search type, handles, and dates.

GrokParaphrased
Code
{
  "tool_code": "from xai_tools.search import XSearch\nsearch = XSearch()\nsearch.search(query='[[search_query]]', 
                search_type='[[search_type]]', # e.g., 'keyword', 'semantic', 'user', 'thread'
                allowed_x_handles=['[[handle1]]', '[[handle2]]'], # Optional, max 20
                excluded_x_handles=['[[handle3]]'], # Optional, max 20
                from_date='[[YYYY-MM-DD]]', # Optional
                to_date='[[YYYY-MM-DD]]', # Optional
                enable_image_understanding=True, # Optional
                enable_video_understanding=True # Optional
               )
}
Language

python

Explanation

This snippet shows how to instantiate and use the XSearch tool from the xai_tools.search library. It demonstrates various parameters like query, search_type, handle filtering, date range restriction, and media understanding.

What it does and when to use it

A Python code snippet illustrating the structure of an X Search tool API call. It includes placeholders for search queries, types, handle filtering (allowed/excluded), date ranges, and enabling image/video analysis for Grok.

Sources and credit

First seen on Subvolts May 20, 2026. Updated Sep 11, 2026. Spotted a problem? Tell us.

Where it shows up
Related in the PlaybookPlaybook →

The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.

Questions people ask

Which AI tools does this work with?
The sources used it with Grok.
Where did this come from?
xAI (xAI Docs: Guides). Subvolts collected, normalized and credited it; the link above opens the original.