FirebaseAILogic Framework Reference

FinishReason

public struct FinishReason : 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

    public static let stop: FinishReason
  • The maximum number of tokens as specified in the request was reached.

    Declaration

    Swift

    public static let maxTokens: FinishReason
  • The token generation was stopped because the response was flagged for safety reasons.

    Note

    When streaming, the content will be empty if content filters blocked the output.

    Declaration

    Swift

    public static let safety: FinishReason
  • The token generation was stopped because the response was flagged for unauthorized citations.

    Declaration

    Swift

    public static let recitation: FinishReason
  • All other reasons that stopped token generation.

    Declaration

    Swift

    public static let other: FinishReason
  • Token generation was stopped because the response contained forbidden terms.

    Declaration

    Swift

    public static let blocklist: FinishReason
  • Token generation was stopped because the response contained potentially prohibited content.

    Declaration

    Swift

    public static let prohibitedContent: FinishReason
  • Token generation was stopped because of Sensitive Personally Identifiable Information (SPII).

    Declaration

    Swift

    public static let spii: FinishReason
  • Token generation was stopped because the function call generated by the model was invalid.

    Declaration

    Swift

    public static let malformedFunctionCall: FinishReason
  • Token generation stopped because generated images contain safety violations.

    Declaration

    Swift

    public static let imageSafety: FinishReason
  • Image generation stopped because generated images have other prohibited content.

    Declaration

    Swift

    public static let imageProhibitedContent: FinishReason
  • Image generation stopped because of other miscellaneous issue.

    Declaration

    Swift

    public static let imageOther: FinishReason
  • The model was expected to generate an image, but none was generated.

    Declaration

    Swift

    public static let noImage: FinishReason
  • Image generation stopped due to recitation.

    Declaration

    Swift

    public static let imageRecitation: FinishReason
  • The response candidate content was flagged for using an unsupported language.

    Declaration

    Swift

    public static let language: FinishReason
  • Model generated a tool call but no tools were enabled in the request.

    Declaration

    Swift

    public static let unexpectedToolCall: FinishReason
  • Model called too many tools consecutively, thus the system exited execution.

    Declaration

    Swift

    public static let tooManyToolCalls: FinishReason
  • Request has at least one thought signature missing.

    Declaration

    Swift

    public static let missingThoughtSignature: FinishReason
  • Finished due to malformed response.

    Declaration

    Swift

    public static let malformedResponse: FinishReason
  • Returns the raw string representation of the FinishReason value.

    Note

    This value directly corresponds to the values in the REST API.

    Declaration

    Swift

    public let rawValue: String