Skip to content

feat(gemini): add Gemini 3 model constants and thinking_level support#1520

Open
EinarasGar wants to merge 2 commits into0xPlaygrounds:mainfrom
EinarasGar:feat/gemini-thinking-level-support
Open

feat(gemini): add Gemini 3 model constants and thinking_level support#1520
EinarasGar wants to merge 2 commits into0xPlaygrounds:mainfrom
EinarasGar:feat/gemini-thinking-level-support

Conversation

@EinarasGar
Copy link

Summary

  • Add model constants for Gemini 3 series (GEMINI_3_FLASH_PREVIEW, GEMINI_3_1_FLASH_LITE_PREVIEW)
  • Add thinking_level: Option<String> field to ThinkingConfig for Gemini 3 models, which use thinkingLevel ("minimal", "low", "medium", "high") instead of Gemini 2.5's thinkingBudget
  • Make thinking_budget optional (Option<u32>) so users can set either field depending on their model family

Context

Gemini 3 models (released March 2026) use a different parameter for controlling reasoning depth. Per the Gemini 3 Developer Guide, thinking_level and thinking_budget are mutually exclusive and cannot be set in the same request.

Both fields use skip_serializing_if = "Option::is_none" so existing Gemini 2.5 configurations that set thinking_budget via additional_params JSON continue to work unchanged.

Example usage

// Gemini 3
GenerationConfig {
    thinking_config: Some(ThinkingConfig {
        thinking_budget: None,
        thinking_level: Some("medium".to_string()),
        include_thoughts: Some(true),
    }),
    ..Default::default()
}

// Gemini 2.5 (unchanged)
GenerationConfig {
    thinking_config: Some(ThinkingConfig {
        thinking_budget: Some(2048),
        thinking_level: None,
        include_thoughts: Some(true),
    }),
    ..Default::default()
}

Test plan

  • Tested with gemini-3-flash-preview — reasoning events emitted correctly
  • Tested with gemini-2.5-flash — thinking budget still works as before
  • cargo build passes

Add model constants for Gemini 3 series:
- GEMINI_3_FLASH_PREVIEW
- GEMINI_3_1_FLASH_LITE_PREVIEW

Add `thinking_level` field to `ThinkingConfig` for Gemini 3 models,
which use `thinkingLevel` (string: "minimal", "low", "medium", "high")
instead of Gemini 2.5's `thinkingBudget` (integer). These fields are
mutually exclusive and cannot be set in the same request.

Make `thinking_budget` optional (`Option<u32>`) so users can set either
field depending on their model family. Both fields are skipped during
serialization when `None`, so existing Gemini 2.5 configurations
continue to work unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant