How are grounded Gemini API citations tied to answer text?

The Citead team, updated

In short. Gemini API URL citation annotations identify their answer text with byte-based start and end offsets.

Definition: A grounded Gemini API citation is attached to a text content block as a url_citation annotation. Its start_index and end_index identify the answer span associated with the annotation's source URL.

Key facts

  • Google's Grounding with Google Search guide, updated 13 October 2026, says grounded output contains inline annotations on the text content block.
  • Each url_citation annotation carries a source URL and indexes that identify the part of the answer it cites.
  • The Gemini Interactions API reference, updated 15 October 2026, defines url_citation as an annotation type and describes its url, title, start_index, and end_index fields.
  • The Interactions API reference measures the start index in bytes and defines the end index as exclusive.
  • The GenerateContent reference documents a separate groundingMetadata shape with groundingSupports and content segment fields.

Which response object contains the span?

In the Interactions API response, the answer appears in a model_output step. That step contains a text content block, and the block can contain an annotations array. Google describes this array as citation information for model-generated content. A URL annotation has type set to url_citation, a url, a title, and the two indexes.

The grounding guide's response example places the annotation beside the answer string, rather than inside the source result record. The source URL therefore belongs to the annotation, while the indexes connect that URL to a range in the text field of the same content block.

How do the indexes select the cited text?

The indexes are byte offsets into the response text. The start position is included and the end position is excluded. Google gives application code that passes the two values directly to a language's substring operation:

if annotation.type == "url_citation":
    cited_text = content_block.text[annotation.start_index:annotation.end_index]

The same guide shows JavaScript using contentBlock.text.slice(annotation.start_index, annotation.end_index). This makes the annotation a range lookup: read the text block, select the interval, then render the selected text with the annotation's title and url. The reference describes the title as the title of the URL and the url as the URL.

The documentation does not specify a separate Unicode character indexing rule for these fields. An integration should therefore preserve the returned text and apply the documented offsets using the API's stated byte semantics.

How does this differ from GenerateContent grounding metadata?

Google documents another response shape for the GenerateContent API. Its GroundingMetadata includes groundingChunks and groundingSupports, and a grounding support has a segment that identifies the content to which the support belongs. The Segment schema uses partIndex, startIndex, and endIndex; both indexes are measured in bytes, with the start inclusive and the end exclusive.

This is related source attribution data, but its field names and nesting differ from the Interactions API's url_citation annotation. Code that parses one shape should select the fields documented for that shape instead of assuming that annotations and groundingSupports are interchangeable.

FAQ

How do I recover the answer text for one URL citation?

Read the annotation's start_index and end_index, then slice the text field of the same content block. Use the annotation's url and title when rendering the selected range.

Is the end index included?

No. The Interactions API reference defines end_index as the end of the attributed segment, exclusive. The documented Python and JavaScript examples pass it as the exclusive endpoint of a slice.

How do I parse a GenerateContent response?

Read the candidate's groundingMetadata and its groundingSupports. For each support, use the nested segment and its byte-based startIndex and endIndex fields, then resolve its grounding chunk indexes.

Sources

  1. Google AI for Developers, "Grounding with Google Search", 13 October 2026
  2. Google AI for Developers, "Gemini Interactions API", 15 October 2026
  3. Google AI for Developers, "Generating content", 13 October 2026

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark