FirebaseAILogic Framework Reference

GenerateContentResponse

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

The model’s response to a generate content request.

  • Token usage metadata for processing the generate content request.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
    public struct UsageMetadata : Sendable
    extension GenerateContentResponse.UsageMetadata: Decodable
  • A list of candidate response content, ordered from best to worst.

    Declaration

    Swift

    public let candidates: [Candidate]
  • A value containing the safety ratings for the response, or, if the request was blocked, a reason for blocking the request.

    Declaration

    Swift

    public let promptFeedback: PromptFeedback?
  • Token usage metadata for processing the generate content request.

    Declaration

    Swift

    public let usageMetadata: UsageMetadata?
  • The response’s content as text, if it exists.

    Note

    This does not include thought summaries; see thoughtSummary for more details.

    Declaration

    Swift

    public var text: String? { get }
  • A summary of the model’s thinking process, if available.

    Important

    Thought summaries are only available when includeThoughts is enabled in the ThinkingConfig. For more information, see the Thinking documentation.

    Declaration

    Swift

    public var thoughtSummary: String? { get }
  • Returns function calls found in any Parts of the first candidate of the response, if any.

    Declaration

    Swift

    public var functionCalls: [FunctionCallPart] { get }
  • Returns inline data parts found in any Parts of the first candidate of the response, if any.

    Declaration

    Swift

    public var inlineDataParts: [InlineDataPart] { get }
  • Initializer for SwiftUI previews or tests.

    Declaration

    Swift

    public init(candidates: [Candidate], promptFeedback: PromptFeedback? = nil,
                usageMetadata: UsageMetadata? = nil)
  • Declaration

    Swift

    public init(from decoder: Decoder) throws