Skip to main content
Lesson 9 of 14 · Grok Models: Complete Guide

Built-in Tool Costs

Lesson 9 of 14 Updated July 30, 2026 Beginner
On this page
  1. xAI Server-Side Tools
  2. Tool Pricing Table
  3. Web Search
  4. X Search
  5. Code Execution
  6. Collections Search
  7. File Attachments
  8. Mixed Client/Server Tools
  9. Calculating Total Request Cost
  10. Key Takeaways

xAI Server-Side Tools

Beyond text tokens, xAI offers built-in tools (server-side tools) that expand Grok models’ capabilities. These tools let the model search the web, query the X platform, execute code, or access files—directly while processing your request.

Each tool has its own cost, separate from token billing. Understanding these costs is essential for budgeting your applications correctly.

Tool Pricing Table

Tool Cost Unit Cost
Web Search $5 / 1,000 calls $0.005 per call
X Search $5 / 1,000 calls $0.005 per call
Code Execution $5 / 1,000 calls $0.005 per call
Collections Search $2.50 / 1,000 calls $0.0025 per call
File Attachments $10 / 1,000 calls $0.01 per call

The Web Search tool lets the model search for up-to-date information on the web while processing your request. This is essential for questions requiring recent data—news, stock prices, weather, events.

At $0.005 per call, this is a modest cost. But beware: if your application triggers a web search on every user request, costs add up. For 10,000 daily requests with web search, budget $50 per day.

The X Search tool is an xAI exclusive: it lets the model search for posts on the X platform (formerly Twitter) in real time. This is a unique tool in the AI API ecosystem, made possible by xAI’s vertical integration with X.

Use cases include real-time monitoring, social media sentiment analysis, trend tracking, and emerging event detection.

Code Execution

The Code Execution tool lets the model run code in a secure environment (sandbox). The model can write and execute code to solve math problems, analyze data, generate charts, or validate algorithms.

This is particularly useful for tasks requiring precise calculation rather than estimation—unit conversion, financial calculations, statistical analysis.

Collections is a feature launched in August 2025 that lets you store documents in xAI and make them accessible to the model via semantic search. At $0.0025 per call, it’s the cheapest tool in the lineup.

Collections are ideal for building RAG (Retrieval-Augmented Generation) systems: you store your documentation, FAQs, and knowledge bases, and the model queries them to produce contextualized answers.

File Attachments

The File Attachments tool lets you attach files to your requests via the Files API (generally available since November 2025). At $0.01 per call, it’s the most expensive tool—reflecting the additional processing required to extract and index file content.

Mixed Client/Server Tools

Since November 2025, xAI has supported mixing client-side and server-side tools in a single request. For example, you can combine a web search (server) with a call to your own API (client) in a single workflow. The model orchestrates the calls and synthesizes the results.

This flexibility is powerful for agentic architectures: the model uses xAI tools when relevant and yours when the information is specific to your domain.

Calculating Total Request Cost

The total cost of a request using tools breaks down as follows:

  1. Input token cost (prompt + context)
  2. Output token cost (response + reasoning)
  3. Tool cost (each tool call billed separately)

For a typical request with web search on grok-4.3 (2,000 input tokens, 500 output tokens, 1 web search call):

  • Input tokens: 2,000 / 1,000,000 × $1.25 = $0.0025
  • Output tokens: 500 / 1,000,000 × $2.50 = $0.00125
  • Web search: $0.005
  • Total: ~$0.009

Here, the tool represents about 57% of the total cost—a reminder that tools can dominate the bill on short requests.

Prices as of August 5, 2026 — prices change regularly: before budgeting, check the current table on the official xAI models and pricing page.

Key Takeaways

  • Five built-in tools, billed between $0.0025 and $0.01 per call
  • Web Search and X Search are the most used ($0.005/call each)
  • File Attachments is the most expensive ($0.01/call)
  • Collections Search is the most economical ($0.0025/call)
  • On short requests, tool costs can exceed token costs
  • Mixed client/server tools have been supported since November 2025