Table of Contents

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 = 0

Default value. This value is unused.

STOP = 1

Natural stop point of the model or provided stop sequence.

MAX_TOKENS = 2

The maximum number of tokens as specified in the request was reached.

SAFETY = 3

The response candidate content was flagged for safety reasons.

RECITATION = 4

The response candidate content was flagged for recitation reasons.

LANGUAGE = 5

The response candidate content was flagged for using an unsupported language.

OTHER = 6

Unknown reason.

BLOCKLIST = 7

Token generation stopped because the content contains forbidden terms.

PROHIBITED_CONTENT = 8

Token generation stopped for potentially containing prohibited content.

SPII = 9

Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII).

MALFORMED_FUNCTION_CALL = 10

The function call generated by the model is invalid.

IMAGE_SAFETY = 11

Token generation stopped because generated images contain safety violations.

MODEL_ARMOR = 12

Token generation stopped due to model armor protection mechanisms. Documented in Vertex AI (google.cloud.aiplatform.v1).

IMAGE_PROHIBITED_CONTENT = 13

Image generation stopped because generated images have prohibited content. Documented in Vertex AI (google.cloud.aiplatform.v1).

IMAGE_RECITATION = 14

Image generation stopped because generated images were flagged for recitation. Documented in Vertex AI (google.cloud.aiplatform.v1).

IMAGE_OTHER = 15

Image generation stopped because of other miscellaneous issues. Documented in Vertex AI (google.cloud.aiplatform.v1).

UNEXPECTED_TOOL_CALL = 16

Model generated a tool call but no tools were enabled in the request. Documented in Gemini API and Vertex AI.

NO_IMAGE = 17

The model was expected to generate an image, but none was generated. Documented in Vertex AI (google.cloud.aiplatform.v1).

TOO_MANY_TOOL_CALLS = 18

Model called too many tools consecutively, thus the system exited execution. Documented in generativelanguagepb (SDK/proto contract).

MISSING_THOUGHT_SIGNATURE = 19

The request is missing a required thought signature from a previous turn.

MALFORMED_RESPONSE = 20

The model produced a malformed response.

ESCALATION = 21

Generation stopped because the request was escalated.

PUP_LIMITED_DISABLED = 22

Generation stopped because the feature is limited or disabled for this project.

CONTINUATION = 23

The 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.

See Also