FirebaseAILogic Framework Reference

FinishReason

@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFinishReason:DecodableProtoEnum,Hashable,Sendable

A value enumerating possible reasons for a model to terminate a content generation request.

  • Natural stop point of the model or provided stop sequence.

    Declaration

    Swift

    publicstaticletstop:FinishReason
  • The maximum number of tokens as specified in the request was reached.

    Declaration

    Swift

    publicstaticletmaxTokens:FinishReason
  • The token generation was stopped because the response was flagged for safety reasons.

    Note

    When streaming, thecontent will be empty if content filters blocked theoutput.

    Declaration

    Swift

    publicstaticletsafety:FinishReason
  • The token generation was stopped because the response was flagged for unauthorized citations.

    Declaration

    Swift

    publicstaticletrecitation:FinishReason
  • All other reasons that stopped token generation.

    Declaration

    Swift

    publicstaticletother:FinishReason
  • Token generation was stopped because the response contained forbidden terms.

    Declaration

    Swift

    publicstaticletblocklist:FinishReason
  • Token generation was stopped because the response contained potentially prohibited content.

    Declaration

    Swift

    publicstaticletprohibitedContent:FinishReason
  • Token generation was stopped because of Sensitive Personally Identifiable Information (SPII).

    Declaration

    Swift

    publicstaticletspii:FinishReason
  • Token generation was stopped because the function call generated by the model was invalid.

    Declaration

    Swift

    publicstaticletmalformedFunctionCall:FinishReason
  • Returns the raw string representation of theFinishReason value.

    Note

    This value directly corresponds to the values in theRESTAPI.

    Declaration

    Swift

    publicletrawValue:String

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-28 UTC.