BerriAI/litellm · error · ValueError

Invalid reasoning effort: {reasoning_effort}

Error message

Invalid reasoning effort: {reasoning_effort}

What it means

Guard mapping the OpenAI-style reasoning_effort to a Gemini thinkingBudget: the value is not one of minimal/low/medium/high/disable/none, so no thinking-budget mapping exists and the request is rejected rather than silently sending a default budget.

Source

Thrown at litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py:843

                "includeThoughts": True,
            }
        elif reasoning_effort == "high":
            return {
                "thinkingBudget": DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET,
                "includeThoughts": True,
            }
        elif reasoning_effort == "disable":
            return {
                "thinkingBudget": DEFAULT_REASONING_EFFORT_DISABLE_THINKING_BUDGET,
                "includeThoughts": False,
            }
        elif reasoning_effort == "none":
            return {
                "thinkingBudget": 0,
                "includeThoughts": False,
            }
        else:
            raise ValueError(f"Invalid reasoning effort: {reasoning_effort}")

    @staticmethod
    def _map_reasoning_effort_to_thinking_level(
        reasoning_effort: str,
        model: str | None = None,
    ) -> GeminiThinkingConfig:
        """
        Map reasoning_effort to thinking_level for Gemini 3+ models.
        Args:
            reasoning_effort: The reasoning effort value
            model: The model name

        Returns:
            GeminiThinkingConfig with thinkingLevel and includeThoughts
        """
        # Check if this is gemini-3-flash which supports MINIMAL thinking level
        # Covers gemini-3-flash, gemini-3-flash-preview, gemini-3.1-flash, gemini-3.1-flash-lite-preview,
        # gemini-3.5-flash, and any future 3.x-flash variants.

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a valid reasoning_effort value (e.g. 'low', 'medium', 'high').
  2. Remove reasoning_effort if not needed.

Example fix

reasoning_effort="low"
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when an invalid reasoning_effort value is passed for Vertex AI Gemini.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/45fb4d63cef3bf8f. Report an issue: GitHub.