Skip to main content
This page shows how to use Grok’s web search and X (Twitter) search on APIYI, verified hands-on on July 13, 2026 (UTC+8).

TL;DR

APIYI fully supports Grok’s official server-side search tools: use the Responses API (/v1/responses) with the web_search / x_search tools. grok-4.5 verifiably performs real searches and returns cited, current results. A default-group key works out of the box.
Endpoint:  POST https://api.apiyi.com/v1/responses
Tools:     tools: [{"type": "web_search"}] or [{"type": "x_search"}]
Model:     grok-4.5 (verified)
The legacy entry point is gone: the search_parameters field on Chat Completions (old Live Search) has been removed by xAI — verified returning 410. Migrate existing code to the Responses API tool format.

Verified Results (2026-07-13)

ToolResultSearches per Q&ALatency
web_search✅ Accurately returned current-week news (correctly found the July 8 Grok 4.5 launch announcement), with source citations5~12s
x_search✅ Accurately returned the latest posts and thread content from a specified X account24~45s
X search is Grok’s differentiator: it searches real-time posts, account activity, and topic discussions on X (Twitter) — a source no other vendor’s search tool covers. Great for social monitoring, trend tracking, and KOL analysis. Note that x_search runs many search rounds and is noticeably slower (~45 s measured); set client timeouts to 120 s or more.

Quick Start

cURL

curl -X POST "https://api.apiyi.com/v1/responses" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.5",
    "tools": [{"type": "web_search"}],
    "input": "What has xAI announced in the past week? Search and cite sources"
  }'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://api.apiyi.com/v1",
)

resp = client.responses.create(
    model="grok-4.5",
    tools=[{"type": "web_search"}],      # for X search use {"type": "x_search"}
    input="What has xAI announced in the past week? Search and cite sources",
)

# 1) Final answer
print(resp.output_text)

# 2) Actual number of searches performed
searches = [i for i in resp.output if i.type == "web_search_call"]
print(f"Performed {len(searches)} searches")

# 3) Server-side tool usage breakdown (for cost auditing)
print(resp.usage.server_side_tool_usage_details)

X Search Example

resp = client.responses.create(
    model="grok-4.5",
    tools=[{"type": "x_search"}],
    input="Search X for the latest posts from the official xAI account and summarize the topics",
)
print(resp.output_text)

Response Structure

The output array contains, in execution order:
item typeMeaning
reasoningThe model’s reasoning (search-strategy planning)
web_search_callOne actually executed web search (x_search produces similar items)
messageThe final answer with inline source citations
usage.server_side_tool_usage_details reports per-tool call counts (web_search_calls / x_search_calls / code_interpreter_calls / mcp_calls, etc.) — worth logging on your side for cost reconciliation.

Billing

A live-search Q&A has two cost components:
ItemNotes
Retrieved-content token costSearch results are injected into the model context and billed at the model’s standard input rate. This is the dominant cost: measured ~27K input tokens for one web_search Q&A (of which ~11K hit the cache at the discounted rate)
Tool call feesServer-side tools may incur per-call fees; refer to APIYI tool pricing and your actual billing statement
x_search runs many rounds (24 searches in one measured Q&A), with correspondingly higher token injection and latency than web_search — estimate costs against your expected query volume. Both the search counts and cached_tokens are self-auditable in the response usage.

Notes

  1. Responses API only: search_parameters on Chat Completions is gone (410) — don’t use it.
  2. Latency expectations: ~12 s for web_search, ~45 s for x_search (measured; varies with task complexity). Set client timeouts ≥ 120 s.
  3. Cost control: constrain search behavior in the prompt (e.g. “search at most 2 times”) and monitor server_side_tool_usage_details.
  4. Verify real search happened: check the output array for web_search_call (or equivalent) items — an answer with body text but no search items came from training data, not the web.

Grok Overview

Model lineup, pricing, and capability matrix

Code Execution & MCP

The other two server-side tools on the Responses API

Cache Billing

The large input-token injections from search pair well with automatic caching

OpenAI Web Search

Web search usage for the GPT series, for comparison