Agent Tools API is xAI's server-side tool suite for agentic workflows. xAI announced it on November 19, 2025 alongside Grok 4.1 Fast, describing it as a way to give agents access to real-time X data, web search, remote code execution, and other hosted tools without forcing developers to manage those systems themselves.[1][2]
The API is integrated with Grok's Responses API surface and is also exposed through xAI's native SDK and the Vercel AI SDK. The central design idea is that Grok decides when to call tools, often using several in parallel, while execution stays on xAI's infrastructure. Developers do not have to handle separate API keys, rate limits, sandboxes, or retrieval pipelines for each tool.[1][3]
At launch, xAI offered both Grok 4.1 Fast and Agent Tools API for free for two weeks ending December 3, 2025, with Grok 4.1 Fast also available free during that window through OpenRouter. After the promotion, xAI priced Grok 4.1 Fast at $0.20 per million input tokens (with caching discounts down to $0.05) and $0.50 per million output tokens, with most server-side tool invocations capped at $5 per 1,000 successful calls.[1][2][4]
The Agent Tools API exposes a small set of hosted tools that Grok can invoke through a single request. Tool names differ slightly between the xAI SDK and the OpenAI-compatible Responses API surface, but the underlying capability is the same.[3][5]
| Tool | xAI SDK name | Responses API name | What it does |
|---|---|---|---|
| Web Search | web_search | web_search | Searches the live web and browses pages for current information, with optional domain allowlists and image understanding |
| X Search | x_search | x_search | Pulls posts, users, and threads from X (formerly Twitter) for real-time social data |
| Code Execution | code_execution | code_interpreter | Runs Python in a sandboxed environment with packages such as NumPy, Pandas, Matplotlib, and SciPy |
| Collections Search | collections_search | file_search | Performs semantic search over uploaded files and document collections |
| View Image | view_image | view_image | Lets the agent open and analyze images encountered during search results |
| Remote MCP Tools | mcp_call | mcp | Connects Grok to external MCP servers over Streaming HTTP or SSE so the agent can call third-party tools |
The web search and X search tools support per-request configuration. Web search accepts up to five entries each in allowed_domains and excluded_domains (the two are mutually exclusive) and an enable_image_understanding flag that activates the view image tool for results encountered during the search.[5]
The code execution tool runs Python statelessly in a secure sandbox with no external network access and limited filesystem access. xAI's docs note that most popular scientific packages are pre-installed, that computations do not persist between requests, and that the tool is best paired with reasoning models for math, data analysis, financial modeling, and scientific computing.[6]
Collections Search powers retrieval over uploaded knowledge bases and is the building block for retrieval-augmented generation workflows on xAI. It accepts an array of collection_ids, a query string, and a max_num_results limit, and returns matches with citation URIs in the form collections://collection_id/files/file_id. Supported file types include PDFs, plain text, and CSV, among others.[7]
Remote MCP Tools let xAI act as the MCP host. Developers pass a server_url and server_label, optionally restrict access with allowed_tools, and provide credentials through an authorization token or arbitrary headers. xAI's documentation says only Streaming HTTP and SSE transports are supported for the MCP connection.[8]
All Agent Tools API tools execute on xAI infrastructure. The model can keep calling tools across multiple turns until it has enough information to answer, and the docs explicitly support multiple server-side tools running in the same request so a single query can combine web search, X search, and code execution.[1][9]
For stateful agent loops, xAI offers two patterns. The first stores the conversation history remotely on the xAI server and lets the client resume from the previous response ID. The second returns encrypted reasoning and encrypted tool output to the client, which is then echoed back on the next request to preserve the agent's intermediate state without exposing it.[9]
Because execution stays on xAI's side, developers do not provision sandboxes, manage tool API quotas, or rotate keys for each integration. The trade-off is that tool runtime, retries, and rate limits are determined by xAI rather than the calling application.
The Agent Tools API returns two kinds of citations for tool-backed answers. A citations attribute on the response object lists every URL the agent encountered during its tool calls; xAI says this list is always returned by default with no extra configuration. Inline citations are markdown links such as [[1]](https://x.ai/news) placed in the generated text where the model references a source.[10]
Inline citations are on by default in the Responses API. In the native xAI SDK, developers enable them with include=["inline_citations"]. xAI notes that enabling the feature does not force the model to cite every claim; the model decides when a citation is appropriate based on the query.[10]
The xAI SDK exposes built-in tools as small Python helpers. A minimal request that turns on web search, X search, and code execution looks like this:
from xai_sdk import Client
from xai_sdk.tools import web_search, x_search, code_execution
import os
client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
model="grok-4.1-fast",
tools=[web_search(), x_search(), code_execution()],
)
response = chat.sample(
"Find the latest 10-K filing for NVIDIA, pull recent X posts about"
" the company's data center revenue, and compute the year-over-year"
" growth rate from the cited numbers."
)
print(response.content)
for citation in response.citations:
print(citation)
The equivalent call against the OpenAI-compatible Responses API at https://api.x.ai/v1/responses uses the names web_search, x_search, and code_interpreter in the tools array.[3][5]
Requests that use server-side tools are billed in two parts: the underlying token usage of the model and a per-call charge for each successful tool invocation. Because the agent decides how many tools to run, the total cost scales with query complexity rather than with a fixed agent fee.[3]
| Cost component | Charge |
|---|---|
| Web Search invocation | $5 per 1,000 successful calls |
| X Search invocation | $5 per 1,000 successful calls |
| Code Execution invocation | $5 per 1,000 successful calls |
| Collections Search invocation | $5 per 1,000 successful calls |
| View Image | Token-based, no per-call fee |
| Remote MCP Tools | Token-based, no per-call fee |
| Grok 4.1 Fast input tokens | $0.20 per 1M (cached as low as $0.05 per 1M) |
| Grok 4.1 Fast output tokens | $0.50 per 1M |
xAI noted in its November 19, 2025 release notes that it had cut tool pricing by up to fifty percent so that no server-side tool exceeds $5 per 1,000 successful calls. The launch promotion made every Agent Tools call free until December 3, 2025.[2][4]
Agent Tools API entered a market where most large model providers already shipped some form of hosted tool layer. The closest analogues are OpenAI's Responses API, Anthropic Claude's tool use, Google's Gemini API tool use, Mistral's Agents API, and AWS Bedrock Agents.
| Provider | Hosted tools offered | Distinguishing feature |
|---|---|---|
| xAI Agent Tools API | Web search, X search, code execution, collections search, view image, remote MCP | Native X data access, single price ceiling of $5 per 1,000 successful tool calls |
| OpenAI Responses API | Web search, file search, code interpreter, computer use, image generation, MCP | Largest third-party tool ecosystem, integrated computer use |
| Anthropic Messages API tool use | Web search, code execution, MCP, computer use | Strong support for parallel tool calls and tool result reasoning, no first-party social data tool |
| Google Gemini API tool use | Google Search grounding, code execution, function calling, URL context | Tight integration with Google Search and YouTube |
| Mistral Agents API | Web search, code interpreter, image generation, document library, MCP | Per-agent design with persistent agent IDs and handoffs |
| AWS Bedrock Agents | Action groups, knowledge bases, code interpreter, multi-agent orchestration | Runs inside AWS accounts with IAM-level controls |
XAI's distinguishing feature is the X search tool, which queries posts, users, and threads from X directly through xAI's pipeline. Other providers can hit X only through general web search or paid third-party connectors.
XAI's launch material focuses on four categories of agent work. Customer support automation uses the long context window of Grok 4.1 Fast plus web and collections search to look up account details, knowledge base entries, and policy documents in the same conversation. Research and agentic search workflows combine web search, X search, and code execution to gather material from many sources and run calculations on top of it.[1]
Long-horizon multi-tool workflows benefit from the encrypted state pattern, which lets an agent run for many turns without the client storing intermediate reasoning. Because the agent runs server-side and does not need a local browser or container, the API also gives Grok browser-like behavior without forcing developers to set up local automation infrastructure.[9]
Agent Tools API fits into a broader push by xAI and X Corp to package Grok as a developer platform rather than only a consumer chatbot. The API ships alongside Grok 4.1 Fast, a long-context tool-calling model with a 2 million token context window aimed at agentic tasks. Agent Tools API is xAI's first serious attempt to compete with OpenAI's Responses API on hosted tooling, and it leverages X data as a defensible advantage that no other provider can match without going through xAI.[1][2]
The November 19, 2025 release also brought tool support for Grok's Voice Agent API, which suggests xAI is pushing the same hosted tool layer across text, voice, and future modalities rather than building separate stacks for each.[3]
The API is tied to the xAI ecosystem. Some tools, especially X search, only make sense if the application's users tolerate a Grok-only architecture, and the underlying X data is governed by X's own terms. The hosted execution model also means the tool surface, runtime limits, and retry logic are decided by xAI rather than the calling application; developers who need their own sandboxing or custom search backends still have to fall back to function calling.
Documentation and community resources are smaller than for the equivalent OpenAI Responses API or Anthropic tool use surfaces, since both shipped earlier and have larger SDK and tutorial ecosystems. Some niche features that competitors expose, such as native computer use or first-party image generation through the same agent surface, are not currently part of Agent Tools API.