In short.
Tool Usage Details is a technical guide for developers tracking xAI agent activity and costs, but it provides neither server-side tool results nor exact prices. It distinguishes attempted calls from successful usage, describes separate X Search item counts and explains why a short final answer can accompany substantial token usage. It also documents differences between SDK chat responses and Responses API output types. The examples and runtime behavior have not been tested.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete captured documentation page at the exact source address, including its examples, tables, billing notes and dated X Search change. Linked pages, including the X Search usage-count definitions, are excluded. Installation, live API behavior, model access, billing accuracy, performance and rights beyond the supplied text were not assessed.
The overview
Identity
Tool Usage Details is an xAI documentation page about requests in which a model repeatedly calls tools while answering. Its source address is [https://docs.x.ai/developers/tools/tool-usage-details.md]. It covers usage reporting and execution controls through Python snippets, field definitions and mapping tables.
Assessment
The guide is useful for interpreting tool activity and investigating differences between attempted work, successful work and billable usage. Its strongest practical points are that failed attempts still appear in call records, X Search uses item-based billing, and max_turns limits assistant turns rather than individual calls.
It supports instrumentation and budgeting decisions, but provides no measured latency, reliability results or complete cost calculation. Invocation records cannot reveal the underlying server-side tool responses.
Users
The intended readers are developers building xAI applications that search, execute code or use other server-side tools. It is especially relevant when adding usage logs, investigating failed calls or separating tools that require local execution from tools handled by the service.
Beginners receive definitions of turns and token categories. Experienced developers get exact field names, tool-category mappings and API-specific output types, although basic API setup knowledge is assumed.
Capabilities
The page shows how to observe streaming tool invocations through chunk.tool_calls and inspect attempted calls through response.tool_calls. Attempt records include an identifier, function name and arguments. Successful execution counts appear in response.server_side_tool_usage.
Its tables map precise function names to categories covering web, image and X search, code execution, image and X video viewing, collections search and MCP tools. It also explains how to identify calls requiring local execution using get_tool_call_type or Responses API output types.
Using it
Requirements
Following the Python example requires Python, the xai_sdk package, an API key supplied through XAI_API_KEY and access to a compatible model and tools. The example names grok-4.7, but the page does not establish current account access, model availability or regional restrictions.
Python and SDK version requirements, installation instructions, quotas and authentication troubleshooting are not supplied. Responses API users also need request-creation details beyond the output-type guidance on this page.
Mechanism
An assistant turn can initiate several tools in parallel. Their results feed the agent's next step internally, while the API exposes invocation information without returning the server-side tool results. Attempt records therefore describe a different set of events from successful-usage counters.
The page defines prompt_tokens as cumulative input across inference requests, completion_tokens as final text output, reasoning_tokens as internal reasoning, cached_prompt_text_tokens as cached prompt text and prompt_image_tokens as visual input. Repeated inference requests include growing conversation history.
For Responses API outputs, function_call requires local execution. The documented server-side types include web_search_call, code_interpreter_call, file_search_call and mcp_call. X Search uses custom_tool_call with an xs_ call_id prefix; the page associates as_ with attachment search.
Setup
The documented SDK sequence is to create a Client using the environment-provided API key, create a chat with a model and tools, optionally set max_turns, append a user message and call chat.sample(). The supplied example enables web_search() and x_search().
For monitoring, the page separately demonstrates inspecting chunk.tool_calls during streaming and response fields after completion. It does not provide a complete streaming initialization example or a full Responses API request.
Example
The Python example configures grok-4.7 with web search, X search and max_turns=3, submits a news question and prints response.content. Three turns do not mean three calls: each turn may invoke several tools.
A separate illustrative usage map contains three successful X Search invocations and two successful Web Search invocations. Those X invocation counts are not sufficient to calculate X Search charges, which depend on fetched posts and user profiles. Neither example supplies measured costs or runtime results.
Assessment & evidence
Limitations
Server-side tool results are unavailable in the API response, so call names and arguments cannot establish exactly what a tool returned. Failed executions, invalid arguments and service issues can also make attempted-call records differ from successful-usage counts.
The default turn cap is unspecified. When the cap is reached, the page says the agent stops making further tool calls and answers using information already gathered. Its speed and thoroughness recommendations are qualitative rather than benchmarked.
Several descriptions refer to SpaceXSI servers despite the xAI documentation address and SDK imports. The page does not explain that naming inconsistency or its implications.
Reasoning
The documented accounting implies that final-answer length alone is a poor estimate of request cost: the agent can accumulate input and reasoning usage across several rounds before producing a short response. Keeping attempted calls, successful calls and X Search item counts separate makes logs more informative.
These distinctions also explain why a turn limit cannot guarantee a specific bill. Parallel calls, cumulative inputs and unspecified rates prevent that conclusion from the supplied evidence.
Alternatives
The page documents two integration routes: xAI SDK chat exposes tool-call records and usage categories, while the Responses API represents activity through typed output entries and usage fields. It does not compare their performance or recommend one universally.
Client-side function calls offer an execution path requiring local handling; server-side tools are handled remotely. The page explains how to distinguish them but does not teach a complete client-side implementation or assess competing providers and monitoring tools.
Evidence
The evidence is the complete page at [https://docs.x.ai/developers/tools/tool-usage-details.md], captured on 2026-11-15T03:58:56.102Z as selected-page.txt, with a recorded size of 8,687 bytes. Its source SHA-256 is 865d12d3f78fc70ac65ba837a4db8402efe6a46e840d82eba1dd0682fa032085.
The source supplies documentation statements, tables and Python examples. It supplies no benchmark measurements or independently observed API behavior. No code or API requests were executed.
Access & freshness
Costs
For tools billed per call, the page says successful executions determine tool charges and failed attempts are not charged. X Search is the stated exception: since September 21, 2026, it is billed per fetched post and user profile. The Responses API reports these as usage.server_side_tool_usage_details.x_posts_fetched and x_users_fetched.
The page supplies no currency prices, model-token rates or worked bill, so actual cost is unknown. Its failed-call billing statement does not establish that an unsuccessful attempt incurs no model-token usage.
Prompt caching is described as reducing costs, but no savings are quantified. max_turns can constrain additional rounds; it does not establish a fixed call count or monetary budget.
Rights
No license or redistribution grant for the page text or examples appears in the supplied content. SDK licensing, commercial reuse rights, API terms and data-handling conditions are not established by this page.
Freshness
The explicit dated change is X Search's move to billing per fetched post and user profile as of September 21, 2026. The November 15, 2026 capture date does not establish the page's publication date or last update.
SDK version compatibility, current prices, model availability and changes after capture are unknown.
Actions
Before adopting the examples, confirm SDK compatibility, access to the named model and tools, current pricing and the applicable turn cap. The page does not establish those deployment-specific details.
Record attempted calls separately from successful usage, collect X Search item counts and identify calls that require local execution. Choose a turn limit for the workload, then measure answer quality, latency and charges in the intended environment; those outcomes remain unassessed here.
