FirebaseAILogic Framework Reference

GenerateContentResponse

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

    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?
  • Returns the model version used to generate the response.

    Note

    If the model version is not specified by the backend, this returns "unknown-model-version".

    Declaration

    Swift

    public let modelVersion: String
  • 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.

    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