Gemini.Validation.ThinkingConfig (GeminiEx v0.8.4)

View Source

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

See: https://ai.google.dev/gemini-api/docs/gemini-3

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

thinking_level()

@type thinking_level() :: :low | :medium | :high

validation_result()

@type validation_result() :: :ok | {:error, String.t()}

Functions

validate(arg1, model)

@spec validate(map() | struct(), String.t()) :: validation_result()

Validate complete thinking config including budget, level, and include_thoughts.

Parameters

  • config: Map or ThinkingConfig struct
  • model: Model name string

Returns

  • :ok if 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"}

validate_budget(budget, model)

@spec validate_budget(integer(), String.t()) :: validation_result()

Validate thinking budget for a specific model.

Parameters

  • budget: Integer budget value
  • model: Model name string

Returns

  • :ok if 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)"}

validate_level(level)

@spec validate_level(thinking_level()) :: validation_result()

Validate thinking level for Gemini 3 models.

Parameters

  • level: Thinking level atom (:low, :medium, or :high)

Returns

  • :ok if 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."}