FirebaseVertexAI Framework Reference

UsageMetadata

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

Token usage metadata for processing the generate content request.

  • The number of tokens in the request prompt.

    Declaration

    Swift

    public let promptTokenCount: Int
  • The total number of tokens across the generated response candidates.

    Declaration

    Swift

    public let candidatesTokenCount: Int
  • The total number of tokens in both the request and response.

    Declaration

    Swift

    public let totalTokenCount: Int
  • The breakdown, by modality, of how many tokens are consumed by the prompt

    Declaration

    Swift

    public let promptTokensDetails: [ModalityTokenCount]
  • The breakdown, by modality, of how many tokens are consumed by the candidates

    Declaration

    Swift

    public let candidatesTokensDetails: [ModalityTokenCount]
  • Declaration

    Swift

    public init(from decoder: any Decoder) throws