FirebaseAI Framework Reference

GroundingMetadata

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GroundingMetadata : Sendable, Equatable, Hashable
extension GroundingMetadata: Decodable

Metadata returned to the client when grounding is enabled.

Important

If using Grounding with Google Search, you are required to comply with the “Grounding with Google Search” usage requirements for your chosen API provider: Gemini Developer API or Vertex AI Gemini API (see Service Terms section within the Service Specific Terms).

  • A list of web search queries that the model performed to gather the grounding information. These can be used to allow users to explore the search results themselves.

    Declaration

    Swift

    public let webSearchQueries: [String]
  • A list of GroundingChunk structs. Each chunk represents a piece of retrieved content (e.g., from a web page) that the model used to ground its response.

    Declaration

    Swift

    public let groundingChunks: [GroundingChunk]
  • A list of GroundingSupport structs. Each object details how specific segments of the model’s response are supported by the groundingChunks.

    Declaration

    Swift

    public let groundingSupports: [GroundingSupport]
  • Google Search entry point for web searches. This contains an HTML/CSS snippet that must be embedded in an app to display a Google Search entry point for follow-up web searches related to the model’s “Grounded Response”.

    Declaration

    Swift

    public let searchEntryPoint: SearchEntryPoint?
  • A struct representing the Google Search entry point.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct SearchEntryPoint : Sendable, Equatable, Hashable
    extension GroundingMetadata.SearchEntryPoint: Decodable
  • Represents a chunk of retrieved data that supports a claim in the model’s response. This is part of the grounding information provided when grounding is enabled.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GroundingChunk : Sendable, Equatable, Hashable
    extension GroundingMetadata.GroundingChunk: Decodable
  • A grounding chunk sourced from the web.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct WebGroundingChunk : Sendable, Equatable, Hashable
    extension GroundingMetadata.WebGroundingChunk: Decodable
  • Provides information about how a specific segment of the model’s response is supported by the retrieved grounding chunks.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) public struct GroundingSupport : Sendable, Equatable, Hashable
  • Declaration

    Swift

    public init(from decoder: Decoder) throws