BerriAI/litellm · error · ValueError
num must be between and , got
Error message
num must be between {NUM_MIN} and {NUM_MAX}, got {self.num} What it means
Error "num must be between {NUM_MIN} and {NUM_MAX}, got {self.num}" thrown in BerriAI/litellm.
Solutions
- Set num within the allowed range shown in the error (NUM_MIN..NUM_MAX).
When it happens
Trigger: Thrown at litellm/llms/apiserpent/search/defaults.py:47 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/1821b65042a0296e.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/apiserpent/search/defaults.py:47
the rest are always sent so behavior is deterministic regardless of any
server-side defaults.
"""
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"View on GitHub (pinned to 77b7c6c40c)