ThinkingConfig
public struct ThinkingConfig : Sendableextension ThinkingConfig: EncodableConfiguration for controlling the “thinking” behavior of compatible Gemini models.
Gemini 2.5 series models and newer utilize a thinking process before generating a response. This allows them to reason through complex problems and plan a more coherent and accurate answer. See the thinking documentation for more details.
-
Initializes a new
ThinkingConfig.Declaration
Swift
public init(thinkingBudget: Int? = nil, includeThoughts: Bool? = nil)Parameters
thinkingBudgetThe maximum number of tokens to be used for the model’s thinking process. The range of supported thinking budget values depends on the model.
- To use the default thinking budget or thinking level for a model, set this value to
nilor omit it. - 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.
includeThoughtsIf true, summaries of the model’s “thoughts” are included in responses.
- To use the default thinking budget or thinking level for a model, set this value to
-
Initializes a
ThinkingConfigwith aThinkingLevel.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
init(thinkingBudget:includeThoughts:)to set a thinking budget instead.Declaration
Swift
public init(thinkingLevel: ThinkingLevel, includeThoughts: Bool? = nil) -
A preset that balances the trade-off between reasoning quality and response speed for a model’s “thinking” process.
Declaration
Swift
struct ThinkingLevel : EncodableProtoEnum, Equatable