FirebaseVertexAI 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.

    Declaration

    Swift

    public var text: 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 }
  • 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