Enum FinishReason
- Namespace
- GenerativeAI.Types
- Assembly
- GenerativeAI.dll
Defines the reason why the model stopped generating tokens.
[JsonConverter(typeof(LenientFinishReasonConverter))]
public enum FinishReason
- Extension Methods
Fields
FINISH_REASON_UNSPECIFIED = 0Default value. This value is unused.
STOP = 1Natural stop point of the model or provided stop sequence.
MAX_TOKENS = 2The maximum number of tokens as specified in the request was reached.
SAFETY = 3The response candidate content was flagged for safety reasons.
RECITATION = 4The response candidate content was flagged for recitation reasons.
LANGUAGE = 5The response candidate content was flagged for using an unsupported language.
OTHER = 6Unknown reason.
BLOCKLIST = 7Token generation stopped because the content contains forbidden terms.
PROHIBITED_CONTENT = 8Token generation stopped for potentially containing prohibited content.
SPII = 9Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII).
MALFORMED_FUNCTION_CALL = 10The function call generated by the model is invalid.
IMAGE_SAFETY = 11Token generation stopped because generated images contain safety violations.
MODEL_ARMOR = 12Token generation stopped due to model armor protection mechanisms. Documented in Vertex AI (google.cloud.aiplatform.v1).
IMAGE_PROHIBITED_CONTENT = 13Image generation stopped because generated images have prohibited content. Documented in Vertex AI (google.cloud.aiplatform.v1).
IMAGE_RECITATION = 14Image generation stopped because generated images were flagged for recitation. Documented in Vertex AI (google.cloud.aiplatform.v1).
IMAGE_OTHER = 15Image generation stopped because of other miscellaneous issues. Documented in Vertex AI (google.cloud.aiplatform.v1).
UNEXPECTED_TOOL_CALL = 16Model generated a tool call but no tools were enabled in the request. Documented in Gemini API and Vertex AI.
NO_IMAGE = 17The model was expected to generate an image, but none was generated. Documented in Vertex AI (google.cloud.aiplatform.v1).
TOO_MANY_TOOL_CALLS = 18Model called too many tools consecutively, thus the system exited execution. Documented in generativelanguagepb (SDK/proto contract).
MISSING_THOUGHT_SIGNATURE = 19The request is missing a required thought signature from a previous turn.
MALFORMED_RESPONSE = 20The model produced a malformed response.
ESCALATION = 21Generation stopped because the request was escalated.
PUP_LIMITED_DISABLED = 22Generation stopped because the feature is limited or disabled for this project.
CONTINUATION = 23The response is incomplete; pass the candidate's continuation token in a follow-up request to resume it.
Remarks
This enum uses a lenient JSON converter that gracefully handles unknown values by falling back to OTHER instead of throwing an exception. This prevents crashes when Google adds new FinishReason values to their API.