Learning resourcesReviewed · xAI

xAI Streaming & Synchronous Requests

This xAI guide helps developers receive responses from Grok requests that use tools, but it omits installation instructions, pricing and error recovery. It covers streaming progress, complete responses, citations and optional tool outputs through JavaScript, Python and HTTP examples.

Researched 15 Nov 2026

In short.

This xAI guide teaches developers how to receive Grok responses during or after tool use, but it does not cover pricing or operational failure handling. Streaming exposes progress while a request runs; synchronous calls return after the complete process finishes. The page also explains how to request underlying tool outputs and documents differences between the native xAI SDK and Responses API. Its examples use grok-4.7. Nothing was executed, so compatibility, performance and runtime behavior remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete selected page at [https://docs.x.ai/developers/tools/streaming-and-sync.md], including its examples, explanatory text and both tool-output tables. Linked pages and external SDK documentation are excluded. No explicit licence notice appears in the supplied page. No code, API request or installation was executed; runtime behavior, compatibility, performance, costs and current service availability were not independently assessed.

The overview

Identity

Streaming & Synchronous Requests is a page in xAI's developer documentation at [https://docs.x.ai/developers/tools/streaming-and-sync.md]. It explains response handling for requests in which a model uses server-side tools, including web search, X search and code execution.

The resource is a technical guide. Its examples demonstrate several client interfaces to xAI rather than providing a standalone application.

Assessment

The guide is useful for deciding whether an application should display progress during tool use or wait for a finished answer. Its strongest practical detail is the distinction between observing tool calls and explicitly requesting their underlying outputs.

xAI recommends streaming for visibility and immediate feedback. The page supplies no measurements showing that streaming improves completion time, answer quality or cost.

Users

The examples suit JavaScript and Python developers integrating Grok into applications, with a curl example for direct HTTP access. Developers building interfaces that show search or tool progress have a clear reason to examine the streaming patterns.

Beginners will need some familiarity with API keys, client libraries and asynchronous iteration. The page assumes those concepts and does not teach package installation or basic API programming.

Capabilities

The JavaScript streaming example handles tool-call events, incremental text and URL sources. Native Python streaming shows tool names, reasoning-token counts and text chunks, then prints citations. Synchronous examples retrieve the finished response; the native Python example also prints usage and server-side tool usage.

The guide lists optional output settings for web search, X search, code execution, collections search, attachment search and MCP in the xAI SDK. Its Responses API table covers web search, code execution, collections search and MCP.

Using it

Requirements

The Python and curl examples use an xAI API key supplied through XAI_API_KEY. Successful use also depends on access to the model and tools named in the request; account eligibility and access requirements are not established by this page.

The JavaScript examples import @ai-sdk/xai and ai. Python examples use either xai_sdk or openai. These are alternative implementation paths. Required package versions, runtime versions and installation commands are not supplied.

Mechanism

Each example configures a model and tools, submits a user request and receives a response. Streaming exposes intermediate events or chunks. Synchronous handling waits for the entire tool-using process before returning the result.

Underlying tool outputs are omitted by default because they can be large. The include field requests them explicitly. For example, native SDK code execution uses code_execution_call_output; Responses API code execution is named code_interpreter and uses code_interpreter_call.outputs. The Responses table says MCP outputs are always returned.

Setup

The JavaScript path configures xai.responses('grok-4.7') with streamText or generateText. The native Python path creates a Client and chat, configures tools and appends a user message. Its streaming example includes verbose_streaming.

The OpenAI Python client example targets xAI by setting base_url to [https://api.x.ai/v1]. Direct HTTP requests target [https://api.x.ai/v1/responses]. A separate native Python example sets store_messages=True to enable the Responses API and prints a response ID for continuing the conversation. Retention details are not explained.

Example

The JavaScript streaming example asks for recent updates about the literal term SpaceXSI and enables web search, X search and code execution. It iterates over fullStream, prints tool names, writes text as it arrives and prints URL citations.

The synchronous counterpart calls generateText and reads text and sources after completion. These examples illustrate response handling; the page provides no captured answer or execution transcript establishing what either request actually returned.

Assessment & evidence

Limitations

The page does not cover retries, timeouts, cancellation, rate limits or recovery from tool failures. It also provides no latency benchmarks or compatibility matrix. No examples were executed for this report.

The Responses API output table has no entry for X search or attachment search, although the native SDK table includes both. Their Responses API output-access behavior is therefore unknown from this page. Tool-call notifications alone also do not establish access to the underlying tool results.

Choosing an approach

Streaming is the documented choice when users or developers need feedback during a potentially long request. Synchronous handling suits an application that only needs the finished answer and can accept less visibility into intermediate steps.

This is a choice about response delivery and observability. The evidence does not establish a difference in model accuracy or tool reliability. The displayed reasoning-token count is a usage signal; the examples do not expose internal reasoning text.

Alternatives

Within the guide, developers can choose JavaScript AI SDK helpers, the native Python xAI SDK, the OpenAI Python client configured for xAI, or direct HTTP requests. Streaming and synchronous handling are presented as alternative ways to receive results.

The page does not compare competing providers or establish which client performs best. Its output tables show that tool names and include values must be matched to the chosen interface.

Evidence

The evidence is the complete documentation page at [https://docs.x.ai/developers/tools/streaming-and-sync.md], retained as selected-page.txt. Its source revision is sha256:298effb1665326421d6ba2afd47655d7dc87ff3bb778537eca097e41336e3887.

This primary source contains code examples, explanatory text and output-option tables. It supports descriptions of documented usage, but supplies no independent performance measurements or execution results.

Access & freshness

Costs

Costs are unknown from this page. It provides no token prices, tool charges, subscription requirements, free allowance or worked billing example.

The native Python examples expose reasoning-token counts, response usage and server-side tool usage. The page does not explain how these values translate into charges or whether streaming and synchronous requests differ in cost.

Rights

No explicit licence or reuse terms appear in the supplied page. Permission to redistribute its text or examples, and the applicable SDK, API and generated-output terms, are not established by this source.

Freshness

The page was captured on 15 November 2026 at 03:48:46.824 UTC. That timestamp identifies the documentation snapshot, not a publication date or verified software release date.

The examples name grok-4.7 but do not pin SDK versions. The page gives no last-updated date, so current model availability and compatibility with particular package releases remain unverified.

Practical next steps

Choose streaming if the application needs visible progress, or synchronous handling if it only needs the completed result. Select one client interface and use its corresponding tool names and include settings.

Before implementation, establish installation requirements, model and tool access, pricing and applicable terms from additional documentation. A first implementation should verify actual events, citations, usage and requested tool outputs with a small request, then address failure handling. These are proposed steps; none were performed.

Evidence for this report

selected-page.txtselected · checked 2026-11-15