Learning resourcesReviewed · xAI

xAI Citations Guide

xAI's Citations guide helps developers add source references to Grok search responses, but enabling inline citations does not guarantee a cited answer. It explains source lists, API-specific defaults, structured citation metadata and streaming.

Researched 15 Nov 2026

In short.

xAI's Citations guide is a developer reference for adding source links to Grok search responses, but the model may omit inline citations even when they are enabled. It distinguishes all encountered sources from references embedded in an answer, explains different defaults across API clients, and documents character offsets for custom rendering. The source list can include URLs unused in the answer, so its presence does not establish claim support. Runtime behavior, citation accuracy and performance are unassessed; pricing and reuse rights are unknown.

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

Coverage includes the complete supplied page at [https://docs.x.ai/developers/tools/citations.md], including configuration defaults, client examples, image embeds, structured metadata, positional indices and streaming guidance. Linked pages and their notices are excluded. SDK implementations, live API behavior, pricing and external reuse terms were not assessed. No code, API requests or rendering tests were run.

The overview

Identity

Citations is an xAI developer documentation page about source references returned by its agent tools API. It covers complete source lists and inline citations, with examples for direct HTTP requests, OpenAI SDK clients, the JavaScript AI SDK and xAI's Python SDK. The original page is [https://docs.x.ai/developers/tools/citations.md].

Assessment

The guide is useful for implementing source displays in Grok search applications. Its strongest practical detail is the distinction between sources encountered during research and sources referenced in the answer. It supplies configuration and response-parsing examples, but no measurements of citation accuracy, source quality, latency or reliability.

Users

Developers building search assistants, research interfaces or source viewers can use this guide to understand which references their application can display. Beginners need basic familiarity with authenticated API requests and response objects. Experienced developers get field names, client-specific defaults and streaming details for custom integrations.

Capabilities

The documented feature returns a default list of encountered source URLs and can insert numbered references into generated text. Structured metadata identifies citation URLs and positions. Citation numbers start at one and are reused when a source appears again. With enable_image_search enabled on web_search, responses may also contain Markdown image embeds.

Streaming examples show URL source events in the JavaScript AI SDK and per-chunk citation metadata plus accumulated final citations in xAI's Python SDK.

Using it

Requirements

The examples use an xAI API key supplied through XAI_API_KEY, a model identifier and search tools. The model shown is grok-4.7. Examples use web_search, with x_search also included in the xAI Python SDK example. Minimum SDK versions, exhaustive model compatibility, account eligibility and rate limits are not specified.

Mechanism

The guide describes response.citations as the source list collected automatically from successful tool executions and returned when the agentic request completes. It can contain URLs that the final answer does not reference.

Responses API output_text blocks carry annotations with type, url, start_index, end_index and title fields. For numbered text citations, title contains the display label. The offsets follow Python slicing: start_index points to the opening bracket and end_index lies immediately after the closing parenthesis. The xAI Python SDK exposes response.inline_citations with web_citation or x_citation data.

Setup

For the Responses API, inline citations are enabled by default; passing include=["no_inline_citations"] disables them. The guide applies this behavior to direct HTTP requests, OpenAI SDK clients for Python and JavaScript, and the JavaScript AI SDK through xai.responses().

The xAI Python SDK uses the gRPC chat API and disables inline citations by default. Enable them with include=["inline_citations"] in chat.create(). The complete encountered-source list requires no additional configuration.

Example

One documented Python example configures the OpenAI client with the xAI API key and base URL [https://api.x.ai/v1], then calls client.responses.create using grok-4.7, the question 'What is xAI?' and the web_search tool. It walks message items in response.output and reads output_text content. A later example reads each annotation's URL, label and character range. These examples were not executed, and their illustrated outputs were not independently verified.

Assessment & evidence

Limitations

Enabling inline citations does not force the model to include them. The encountered-source list can include sources unused in the final answer. When inline citations are disabled, annotations may remain, but the page says they lack positional references into response text.

The page does not establish whether cited sources support individual claims, whether links remain accessible, or how offsets behave across different language string representations. Streaming interruption handling and citation completeness after an interrupted request are also unspecified.

Reasoning

The practical value is control over how source references are displayed and retained. The documented structures allow an application to present consulted URLs separately from references attached to an answer. This is an implementation inference from the available fields; the page supplies no evidence that a particular display improves reader understanding or factual accuracy.

Alternatives

The guide documents several integration routes: direct HTTP, OpenAI SDK clients for Python or JavaScript, the JavaScript AI SDK and xAI's Python SDK. Their citation defaults and access patterns differ. Competing citation services and retrieval libraries are not compared, so their relative accuracy, cost and suitability are unknown.

Evidence

The evidence is the complete supplied xAI Citations documentation page at [https://docs.x.ai/developers/tools/citations.md]. It contains explanatory text, a configuration table, code snippets and illustrative response objects. These support an account of the documented interface; they do not establish successful execution or independently validate factual statements inside sample answers.

Access & freshness

Costs

The page provides no model pricing, search-tool fees, billing rules or usage allowances. Total operating cost and whether citation output carries any separate charge are unknown.

Rights

The supplied page contains no license or redistribution terms for its text or code examples, so permission to redistribute them is unknown. It also does not establish reuse rights for external material or images referenced by generated citations.

Freshness

The supplied snapshot was captured on 15 November 2026. The page provides no publication date, last-update date or minimum SDK versions. Its examples use grok-4.7, but do not establish the latest available model. Dates and timestamps inside illustrative responses do not establish when the documentation was updated.

Actions

Choose an API client and apply its documented inline-citation setting. Keep encountered sources distinct from inline references, and handle answers that contain no inline citations. Before relying on a custom renderer, verify offsets against actual response text, including Unicode text, repeated citations and streamed output. Confirm model access, SDK compatibility, pricing and reuse terms separately.

Evidence for this report

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