ThinkingConfig.Builder

class ThinkingConfig.Builder


Summary

Public constructors

Public functions

ThinkingConfig
ThinkingConfig.Builder
setIncludeThoughts(includeThoughts: Boolean)

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

ThinkingConfig.Builder
setThinkingBudget(thinkingBudget: Int)

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

ThinkingConfig.Builder

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

Public constructors

Builder

Builder()

Public functions

build

fun build(): ThinkingConfig

setIncludeThoughts

fun setIncludeThoughts(includeThoughts: Boolean): ThinkingConfig.Builder

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

fun setThinkingBudget(thinkingBudget: Int): ThinkingConfig.Builder

Sets the amount of thinking the model can do to generate a response, defined as a ThinkingBudget 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

fun setThinkingLevel(thinkingLevel: ThinkingLevel): ThinkingConfig.Builder

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

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

Public properties

includeThoughts

var includeThoughts: Boolean?

thinkingBudget

var thinkingBudget: Int?

thinkingLevel

var thinkingLevel: ThinkingLevel?