Gemini.Validation.ThinkingConfig (GeminiEx v0.8.4)
View SourceValidation for thinking configuration parameters based on model capabilities.
Gemini 3 Models
Use thinking_level for Gemini 3 models:
:low- Minimizes latency and cost:high- Maximizes reasoning depth (default)
Note: :medium is not currently supported.
Gemini 2.5 Models
Gemini 2.5 series models support thinking budgets with model-specific ranges:
- 2.5 Pro: 128-32,768 tokens (cannot disable with 0)
- 2.5 Flash: 0-24,576 tokens (can disable)
- 2.5 Flash Lite: 0 or 512-24,576 tokens
Special value -1 enables dynamic thinking (model decides budget) for all models.
Important
You cannot use both thinking_level and thinking_budget in the same request.
Doing so will return a 400 error from the API.
Summary
Functions
Validate complete thinking config including budget, level, and include_thoughts.
Validate thinking budget for a specific model.
Validate thinking level for Gemini 3 models.
Types
@type thinking_level() :: :low | :medium | :high
@type validation_result() :: :ok | {:error, String.t()}
Functions
@spec validate(map() | struct(), String.t()) :: validation_result()
Validate complete thinking config including budget, level, and include_thoughts.
Parameters
config: Map or ThinkingConfig structmodel: Model name string
Returns
:okif valid{:error, message}if invalid
Examples
iex> Gemini.Validation.ThinkingConfig.validate(%{thinking_level: :low}, "gemini-3-pro-preview")
:ok
iex> Gemini.Validation.ThinkingConfig.validate(%{thinking_budget: 1024, thinking_level: :low}, "gemini-3-pro-preview")
{:error, "Cannot use both thinking_level and thinking_budget in the same request"}
@spec validate_budget(integer(), String.t()) :: validation_result()
Validate thinking budget for a specific model.
Parameters
budget: Integer budget valuemodel: Model name string
Returns
:okif valid{:error, message}with helpful error message
Examples
iex> Gemini.Validation.ThinkingConfig.validate_budget(1024, "gemini-2.5-flash")
:ok
iex> Gemini.Validation.ThinkingConfig.validate_budget(0, "gemini-2.5-pro")
{:error, "Gemini 2.5 Pro cannot disable thinking (minimum budget: 128)"}
@spec validate_level(thinking_level()) :: validation_result()
Validate thinking level for Gemini 3 models.
Parameters
level: Thinking level atom (:low,:medium, or:high)
Returns
:okif valid{:error, message}if invalid
Examples
iex> Gemini.Validation.ThinkingConfig.validate_level(:low)
:ok
iex> Gemini.Validation.ThinkingConfig.validate_level(:medium)
{:error, "Thinking level :medium is not currently supported. Use :low or :high."}