BerriAI/litellm · error · ValueError
model parameter is required but was None. Please provide a v
Error message
model parameter is required but was None. Please provide a valid model name.
What it means
Early guard in get_llm_provider: the model argument is None, so provider resolution is impossible. The ValueError is subsequently wrapped into a BadRequestError ('GetLLMProvider Exception - ...') by the enclosing except block, so callers see a BadRequestError mentioning the None model.
Source
Thrown at litellm/litellm_core_utils/get_llm_provider_logic.py:149
model: str,
custom_llm_provider: str | None = None,
api_base: str | None = None,
api_key: str | None = None,
litellm_params: GenericLiteLLMParams | None = None,
) -> tuple[str, str, str | None, str | None]:
"""
Returns the provider for a given model name - e.g. 'azure/chatgpt-v-2' -> 'azure'
For router -> Can also give the whole litellm param dict -> this function will extract the relevant details
Raises Error - if unable to map model to a provider
Return model, custom_llm_provider, dynamic_api_key, api_base
"""
try:
# Early validation - model is required
if model is None:
raise ValueError("model parameter is required but was None. Please provide a valid model name.")
if litellm.LiteLLMProxyChatConfig._should_use_litellm_proxy_by_default(
litellm_params=cast(LiteLLM_Params | None, litellm_params)
):
return litellm.LiteLLMProxyChatConfig.litellm_proxy_get_custom_llm_provider_info(
model=model, api_base=api_base, api_key=api_key
)
## IF LITELLM PARAMS GIVEN ##
if litellm_params:
if custom_llm_provider is None and api_base is None and api_key is None:
custom_llm_provider = litellm_params.custom_llm_provider
api_base = litellm_params.api_base
api_key = litellm_params.api_key
dynamic_api_key = None
# check if llm provider provided
# AZURE AI-Studio Logic - Azure AI Studio supports AZURE/CohereView on GitHub (pinned to 6c2dcb801b)
Solutions
- Find where the None originates: log the value right before the call.
- For Router/proxy configs, ensure every model_list entry has model_name and litellm_params.model.
- Default to a concrete fallback model when dynamic selection returns nothing.
Example fix
# before
model = os.getenv('MODEL') # unset -> None
litellm.completion(model=model, messages=msgs)
# after
model = os.getenv('MODEL') or 'gpt-4o-mini'
litellm.completion(model=model, messages=msgs) Defensive patterns
Strategy: validation
Validate before calling
def model_arg_valid(model) -> bool:
return isinstance(model, str) and len(model.strip()) > 0 Type guard
function isModelName(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await litellm.completion({ model, messages });
} catch (e) {
if (e instanceof litellm.BadRequestError && /model parameter is required/.test(e.message)) { /* fix model source */ }
} Prevention
- Assert model is a non-empty string before every call.
- Give router/proxy model_list entries explicit model_name and litellm_params.model.
- Default dynamic model selection to a known-good fallback.
When it happens
Trigger: Calling litellm.completion(model=None, ...), passing a config field that is unset (router model_list entry without model), or a variable that was never populated (env var read returned None).
Common situations: Router/proxy config YAML missing the model_name/model field, template code with placeholder variables, or dynamic model selection logic that yields None.
Related errors
- Event hook {hook} is not in the supported event hooks {suppo
- Event hook {event_hook} is not in the supported event hooks
- Invalid environment: {environment}. Please use one of the fo
- bucket_name must be provided for S3 destination
- Export format '{self.export_format}' not supported. Use 'par
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/eb0d6a9a43351fb3.
Report an issue: GitHub.