FirebaseAILogic Framework Reference Stay organized with collections Save and categorize content based on your preferences.
FinishReason
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructFinishReason:DecodableProtoEnum,Hashable,SendableA 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:FinishReasonThe maximum number of tokens as specified in the request was reached.
Declaration
Swift
publicstaticletmaxTokens:FinishReasonThe token generation was stopped because the response was flagged for safety reasons.
Note
When streaming, the
contentwill be empty if content filters blocked theoutput.Declaration
Swift
publicstaticletsafety:FinishReasonThe token generation was stopped because the response was flagged for unauthorized citations.
Declaration
Swift
publicstaticletrecitation:FinishReasonAll other reasons that stopped token generation.
Declaration
Swift
publicstaticletother:FinishReasonToken generation was stopped because the response contained forbidden terms.
Declaration
Swift
publicstaticletblocklist:FinishReasonToken generation was stopped because the response contained potentially prohibited content.
Declaration
Swift
publicstaticletprohibitedContent:FinishReasonToken generation was stopped because of Sensitive Personally Identifiable Information (SPII).
Declaration
Swift
publicstaticletspii:FinishReasonToken generation was stopped because the function call generated by the model was invalid.
Declaration
Swift
publicstaticletmalformedFunctionCall:FinishReasonReturns the raw string representation of the
FinishReasonvalue.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.