FirebaseAILogic Framework Reference

GeneratedContent

struct GeneratedContent : Sendable
extension FirebaseAI.GeneratedContent: Equatable
extension FirebaseAI.GeneratedContent: CustomDebugStringConvertible

Structured content generated by a model.

Public Preview: This API is a public preview and may be subject to change.

  • Undocumented

    Declaration

    Swift

    public let kind: Kind
  • The generation identifier associated with this content, if any.

    Public Preview: This API is a public preview and may be subject to change.

    Declaration

    Swift

    public let generationID: FirebaseAI.GenerationID?
  • Creates a new GeneratedContent from a JSON string.

    Public Preview: This API is a public preview and may be subject to change.

    Throws

    An error if the JSON is invalid.

    Declaration

    Swift

    public init(json: String) throws

    Parameters

    json

    The JSON string representation of the generated content.

  • The JSON string representation of the generated content.

    Public Preview: This API is a public preview and may be subject to change.

    Declaration

    Swift

    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    public var jsonString: String { get }
  • Decodes the generated content into the specified type.

    Public Preview: This API is a public preview and may be subject to change.

    Throws

    An error if decoding fails.

    Declaration

    Swift

    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    public func value<Value>(_ type: Value.Type = Value.self) throws -> Value
      where Value: FoundationModels.ConvertibleFromGeneratedContent

    Parameters

    type

    The type to decode the content into.

    Return Value

    The decoded value.

  • Decodes a specific property of the generated content into the specified type.

    Public Preview: This API is a public preview and may be subject to change.

    Throws

    An error if decoding fails or the property does not exist.

    Declaration

    Swift

    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    public func value<Value>(_ type: Value.Type = Value.self,
                             forProperty property: String) throws -> Value
      where Value: FoundationModels.ConvertibleFromGeneratedContent

    Parameters

    type

    The type to decode the property into.

    property

    The name of the property to decode.

    Return Value

    The decoded value.

  • Decodes an optional specific property of the generated content into the specified type.

    Public Preview: This API is a public preview and may be subject to change.

    Throws

    An error if decoding fails.

    Declaration

    Swift

    @available(iOS 26.0, macOS 26.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    public func value<Value>(_ type: Value?.Type = Value?.self,
                             forProperty property: String) throws -> Value?
      where Value: FoundationModels.ConvertibleFromGeneratedContent

    Parameters

    type

    The optional type to decode the property into.

    property

    The name of the property to decode.

    Return Value

    The decoded value, or nil if the property does not exist or is null.

  • A boolean indicating whether the generated content is complete.

    Public Preview: This API is a public preview and may be subject to change.

    Declaration

    Swift

    public let isComplete: Bool
  • The kinds of values that can be represented by generated content.

    Public Preview: This API is a public preview and may be subject to change.

    Declaration

    Swift

    enum Kind : Sendable
    extension FirebaseAI.GeneratedContent.Kind: Equatable
  • Declaration

    Swift

    public static func == (lhs: FirebaseAI.GeneratedContent,
                           rhs: FirebaseAI.GeneratedContent) -> Bool
  • Declaration

    Swift

    public var debugDescription: String { get }