ThinkingConfig.Builder

public final class ThinkingConfig.Builder


Summary

Public constructors

Public methods

final @NonNull ThinkingConfig
final @NonNull ThinkingConfig.Builder
setIncludeThoughts(boolean includeThoughts)

Indicates whether to request the model to include the thoughts parts in the response.

final @NonNull ThinkingConfig.Builder
setThinkingBudget(int thinkingBudget)

Sets the amount of thinking the model can do to generate a response, defined as a in tokens.

final @NonNull ThinkingConfig.Builder

Sets the amount of thinking the model can do to generate a response, defined as a .

Public fields

includeThoughts

public final Boolean includeThoughts

thinkingBudget

public final Integer thinkingBudget

thinkingLevel

public final ThinkingLevel thinkingLevel

Public constructors

Builder

public Builder()

Public methods

build

public final @NonNull ThinkingConfig build()

setIncludeThoughts

public final @NonNull ThinkingConfig.Builder setIncludeThoughts(boolean includeThoughts)

Indicates whether to request the model to include the thoughts parts in the response.

Keep in mind that once enabled, you should check for the isThought property when processing a Part instance to correctly handle both thoughts and the actual response.

The default value is false.

setThinkingBudget

public final @NonNull ThinkingConfig.Builder setThinkingBudget(int thinkingBudget)

Sets the amount of thinking the model can do to generate a response, defined as a in tokens.

The range of supported thinking budget values depends on the model.

  • To disable thinking, when supported by the model, set this value to 0.

  • To use dynamic thinking, allowing the model to decide on the thinking budget based on the task, set this value to -1.

setThinkingLevel

public final @NonNull ThinkingConfig.Builder setThinkingLevel(@NonNull ThinkingLevel thinkingLevel)

Sets the amount of thinking the model can do to generate a response, defined as a .

If you don't specify a thinking level, Gemini will use the model's default dynamic thinking level.

Important: Gemini 2.5 series models do not support thinking levels; use setThinkingBudget to set a thinking budget instead.

Parameters
@NonNull ThinkingLevel thinkingLevel

A preset that controls the model's "thinking" process. Use ThinkingLevel.LOW for faster responses on less complex tasks, and ThinkingLevel.HIGH for better reasoning on more complex tasks.