BerriAI/litellm · error · ValueError

pages must be between

Error message

pages must be between {PAGES_MIN} and {PAGES_MAX}, got {self.pages}

What it means

Error "pages must be between {PAGES_MIN} and {PAGES_MAX}, got {self.pages}" thrown in BerriAI/litellm.

Solutions

  1. Set pages within the allowed range shown in the error (PAGES_MIN..PAGES_MAX).

When it happens

Trigger: Thrown at litellm/llms/apiserpent/search/defaults.py:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at litellm/llms/apiserpent/search/defaults.py:49

    """

    engine: SearchEngine = "google"
    country: str = "us"
    num: int = 10
    format: ResponseFormat = "full"
    pages: int | None = None
    freshness: Freshness | None = None
    safe: SafeSearch | None = None
    language: str | None = None
    pixel_position: bool | None = None

    def __post_init__(self) -> None:
        # num's deep-search floor (NUM_MIN_DEEP) is endpoint-specific and enforced
        # in the transform layer; here we only bound the absolute range.
        if not NUM_MIN <= self.num <= NUM_MAX:
            raise ValueError(f"num must be between {NUM_MIN} and {NUM_MAX}, got {self.num}")
        if self.pages is not None and not PAGES_MIN <= self.pages <= PAGES_MAX:
            raise ValueError(f"pages must be between {PAGES_MIN} and {PAGES_MAX}, got {self.pages}")

    def to_request_params(self) -> dict:
        """Return non-None fields as request params, booleans lowercased."""
        params: Final[dict] = {}
        for key, value in asdict(self).items():
            if value is None:
                continue
            params[key] = str(value).lower() if isinstance(value, bool) else value
        return params

    @classmethod
    def field_names(cls) -> set:
        return set(cls.__dataclass_fields__.keys())


QUICK_SEARCH_PATH: Final = "/api/search/quick"
DEEP_SEARCH_PATH: Final = "/api/search"

View on GitHub (pinned to 77b7c6c40c)