X (Twitter) Search Integration for Hermes Agent

Search X (Twitter) posts, profiles, and threads directly from Hermes Agent using Grok.

Data & On-Chainintermediate8 min readVerified Jul 27, 2026

The x_search tool integrates Hermes Agent with xAI's Grok-powered X (Twitter) search, allowing the agent to discover public posts, profiles, threads, and current discussions directly from X. Once wired up, the agent can query X for real-time reactions, claims, and conversations, returning synthesized answers with citations to the original posts.

What It Does

  • Searches X (Twitter) posts, profiles, and threads directly from the agent.
  • Uses xAI's built-in x_search tool on the Responses API at https://api.x.ai/v1/responses.
  • Grok runs the search server-side and returns synthesized results with citations to the originating posts.
  • Returns a JSON response containing:
    • answer, synthesized text response from Grok.
    • citations, citations returned by the Responses API top-level field.
    • inline_citations, url_citation annotations extracted from the message body (each with url, title, start_index, end_index).
    • degraded, true when any narrowing filter (allowed_x_handles, excluded_x_handles, from_date, to_date) was set AND both citation channels came back empty. In that case the answer was synthesized from the model's own knowledge rather than the X index, so treat it as unsourced. false otherwise (including the "no filters set" case, a broad unsourced answer is just an answer, not a filter miss).
    • degraded_reason, short string naming which filters were active, or null when degraded is false.
    • credential_source, "xai-oauth" if OAuth resolved, "xai" if API key resolved.
    • model, query, provider, tool, success.

This tool is specifically for read-only public X discovery: current discussion, reactions, claims, profiles, threads, and synthesized answers with citations. It is not for posting, replying, liking, DMs, media upload, deleting, or proving that an authenticated X account changed state. For those actions, use the xurl skill.

Use x_search instead of web_search when you specifically want current discussion, reactions, or claims on X. For general web pages, keep using web_search / web_extract.

Setup

Authentication

x_search registers when either xAI credential path is available:

Credential SourceSetup
SuperGrok / X Premium+ OAuth (preferred)Browser login at accounts.x.ai, refreshed automatically hermes auth add xai-oauth, see xAI Grok OAuth (SuperGrok / X Premium+)
XAI_API_KEYPaid xAI API key. Set in ~/.hermes/.env

Both hit the same endpoint with the same payload, the only difference is the bearer token. When both are configured, SuperGrok OAuth wins so x_search runs against your subscription quota instead of paid API spend.

The tool's check_fn runs the xAI credential resolver every time the model's tool list is rebuilt. A True return means the bearer is fetchable AND non-empty AND (if it had expired) successfully refreshed. Revoked tokens with a failed refresh hide the tool from the schema; the model simply can't see it.

Enabling the tool

Auto-enables when xAI credentials (OAuth token or XAI_API_KEY) are present. Disable explicitly via hermes tools โ†’ Search โ†’ x_search if you don't want this.

hermes tools
# โ†’ ๐Ÿฆ X (Twitter) Search (press space to toggle on)

The picker offers two credential choices:

  • xAI Grok OAuth (SuperGrok / Premium+), opens the browser to accounts.x.ai if you're not already logged in
  • xAI API key, prompts for XAI_API_KEY

Either choice satisfies the gating. You can pick whichever credentials you already have; the tool works identically with both. If both end up configured, OAuth is preferred at call time.

Configuration

# ~/.hermes/config.yaml
x_search:
  # xAI model used for the Responses call.
  # grok-4.5 is the recommended default; any Grok model
  # with x_search tool access works.
  model: grok-4.5

  # Optional reasoning effort: low, medium, high, or xhigh. When omitted,
  # the selected model's default applies. xhigh is supported only by
  # models that document it, such as grok-4.20-multi-agent.
  # reasoning_effort: low

  # Request timeout in seconds. x_search can take 60, 120s for
  # complex queries, the default is generous. Minimum: 30.
  timeout_seconds: 180

  # Number of automatic retries on 5xx / ReadTimeout / ConnectionError.
  # Each retry backs off (1.5x attempt seconds, capped at 5s).
  retries: 2

reasoning_effort is sent to the xAI Responses API as reasoning: {effort: ...}. Leave it unset for models that do not support configurable reasoning. Invalid values fail before an API request is made.

Configuration Reference

OptionTypeDefaultDescription
modelstringgrok-4.5xAI model used for the Responses call. Any Grok model with x_search tool access works.
reasoning_effortstringmodel defaultOptional reasoning effort: low, medium, high, or xhigh. xhigh is supported only by models that document it, such as grok-4.20-multi-agent.
timeout_secondsinteger180Request timeout in seconds. Minimum: 30. x_search can take 60, 120s for complex queries.
retriesinteger2Number of automatic retries on 5xx / ReadTimeout / ConnectionError. Each retry backs off (1.5x attempt seconds, capped at 5s).

Tool parameters

The agent calls x_search with these arguments:

ParameterTypeDescription
querystring (required)What to look up on X.
allowed_x_handlesstring arrayOptional list of handles to include exclusively (max 10). Leading @ is stripped.
excluded_x_handlesstring arrayOptional list of handles to exclude (max 10). Mutually exclusive with allowed_x_handles.
from_datestringOptional YYYY-MM-DD start date.
to_datestringOptional YYYY-MM-DD end date.
enable_image_understandingbooleanAsk xAI to analyze images attached to matching posts.
enable_video_understandingbooleanAsk xAI to analyze videos attached to matching posts.

Date validation

from_date / to_date are validated client-side before the HTTP call:

  • Both, if provided, must parse as YYYY-MM-DD.
  • When both are set, from_date must be on or before to_date.
  • from_date must not be later than today UTC, no posts can exist in a window that hasn't started yet, so the call would be guaranteed to return zero citations.
  • to_date in the future is allowed (callers may legitimately request "from yesterday to tomorrow" to catch posts as they arrive).

Validation failures surface as a structured {"error": "..."} tool result, never as an HTTP call to xAI.

How It Works

x_search is backed by xAI's built-in x_search tool on the Responses API at https://api.x.ai/v1/responses. Grok itself runs the search server-side and returns synthesized results with citations to the originating posts.

The tool's check_fn runs the xAI credential resolver every time the model's tool list is rebuilt. A True return means the bearer is fetchable AND non-empty AND (if it had expired) successfully refreshed. Revoked tokens with a failed refresh hide the tool from the schema; the model simply can't see it.

When the agent calls x_search, it sends the parameters to the xAI Responses API. The API returns a JSON response with the fields described above. The agent then uses the answer and citations to reply to the user.

x_search vs xurl

Hermes can expose two different X surfaces:

SurfaceUse it forDo not use it for
x_searchRead-only public X discovery: current discussion, reactions, claims, profiles, threads, and synthesized answers with citations.Posting, replying, liking, DMs, media upload, deleting, or proving that an authenticated X account changed state.
xurl skillExact or authenticated X API work: post, reply, read, like, dm, timelines, mentions, media upload, account-specific reads, and raw v2 endpoints.Broad Grok-synthesized public X research when x_search is available and no authenticated account context is needed.

For mixed workflows, use x_search to discover candidate public posts, then switch to xurl read or another exact xurl command after the target post/user/action is clear. Any state-changing X action must be confirmed by xurl output or the X API response; an x_search answer is never evidence that a write happened.

Requirements and Limitations

  • Requires xAI credentials: either a SuperGrok / X Premium+ OAuth token or a paid xAI API key (XAI_API_KEY).
  • The tool auto-enables when credentials are present, but can be disabled via hermes tools.
  • The x_search tool is specifically for read-only public X discovery. It cannot post, reply, like, DM, upload media, delete, or prove that an authenticated X account changed state.
  • The allowed_x_handles and excluded_x_handles parameters are mutually exclusive.
  • Maximum of 10 handles for allowed_x_handles or excluded_x_handles.
  • Date validation is client-side; from_date must not be later than today UTC.
  • to_date in the future is allowed.
  • The reasoning_effort parameter is optional and only supported by models that document it (e.g., grok-4.20-multi-agent for xhigh). Invalid values fail before an API request is made.
  • The degraded flag indicates that filters were set but no citations were returned, meaning the answer is unsourced.
  • xAI index gaps may cause some active accounts to intermittently fail to surface in x_search even when they post regularly.

Troubleshooting

"No xAI credentials available"

The tool surfaces this when both auth paths fail. Either set XAI_API_KEY in ~/.hermes/.env or run hermes auth add xai-oauth and complete the browser login. Then restart your session so the agent re-reads the tool registry.

"x_search is not enabled for this model"

The configured x_search.model doesn't have access to the server-side x_search tool. Switch to grok-4.5 (the default) or another Grok model that supports it. Check the xAI documentation for the current list.

Tool doesn't appear in the schema

Two possible causes:

  1. Toolset not enabled. Run hermes tools and confirm ๐Ÿฆ X (Twitter) Search is checked.
  2. No xAI credentials. The check_fn returns False, so the schema stays hidden. Run hermes auth status to confirm xai-oauth login state, and check that XAI_API_KEY is set (if you're using the API-key path).

degraded: true, answer with no citations

When you used allowed_x_handles, excluded_x_handles, or a date range and the response comes back with degraded: true, xAI's X index returned no matching posts but Grok still produced a synthesized answer from its own training data. The answer is unsourced, do not treat it as a real X result.

Causes worth checking:

  • Typo in the handle. Strip the @, double-check spelling, and confirm the account exists.
  • Date range too narrow or sliding past today's posts; widen and retry.
  • xAI index gap. Some active accounts intermittently fail to surface in x_search even when they post regularly. Retry after a few minutes, or use the xurl skill for direct X API reads when you need an exact handle's timeline.

Sources & References

This page was researched from 1 independent source, combined and verified for completeness.

Newsletter

The #1 AI Newsletter

The most important ai updates, guides, and fixes โ€” one weekly email.

No spam, unsubscribe anytime. Privacy policy

Other Hermes Agent integrations