from google.genai import types def thinking_config(level: str | None) -> types.ThinkingConfig | None: """Use a supported reasoning level, or omit it for the model default.""" if level is None: return None if level not in {"minimal", "low", "medium", "high"}: raise ValueError( f"Invalid Gemini thinking level {level!r}; " 'expected "minimal", "low", "medium", "high", or None' ) return types.ThinkingConfig(thinking_level=level)