{"record":{"id":"c2173f9ef35a40a0","repo":"BerriAI/litellm","slug":"model-param-not-passed-in","errorCode":null,"errorMessage":"model param not passed in.","messagePattern":"model param not passed in\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/main.py","lineNumber":4996,"sourceCode":"        api_key (str, optional): API key (default is None).\n        model_list (list, optional): List of api base, version, keys\n        extra_headers (dict, optional): Additional headers to include in the request.\n\n        LITELLM Specific Params\n        mock_response (str, optional): If provided, return a mock completion response for testing or debugging purposes (default is None).\n        custom_llm_provider (str, optional): Used for Non-OpenAI LLMs, Example usage for bedrock, set model=\"amazon.titan-tg1-large\" and custom_llm_provider=\"bedrock\"\n        max_retries (int, optional): The number of retries to attempt (default is 0).\n    Returns:\n        ModelResponse: A response object containing the generated completion and associated metadata.\n\n    Note:\n        - This function is used to perform completions() using the specified language model.\n        - It supports various optional parameters for customizing the completion behavior.\n        - If 'mock_response' is provided, a mock completion response is returned for testing or debugging.\n    \"\"\"\n    ### VALIDATE Request ###\n    if model is None:\n        raise ValueError(\"model param not passed in.\")\n    # validate messages\n    messages = validate_and_fix_openai_messages(messages=messages)\n    tools = validate_and_fix_openai_tools(tools=tools)\n    # validate tool_choice\n    tool_choice = validate_chat_completion_tool_choice(tool_choice=tool_choice)\n    # validate optional params\n    stop = validate_openai_optional_params(stop=stop)\n    # normalize camelCase thinking keys (e.g. budgetTokens -> budget_tokens)\n    thinking = validate_and_fix_thinking_param(thinking=thinking)\n\n    ######### unpacking kwargs #####################\n    args: Final = _locals_snapshot(locals())\n\n    # Set by the responses->completion fallback so completion() does not bridge\n    # back to the Responses API: that round-trip mutually recurses forever for a\n    # model whose model_cost mode is \"responses\" but whose provider has no\n    # Responses API config (get_provider_responses_api_config -> None).\n    skip_responses_api_bridge: Final = kwargs.pop(\"_skip_responses_api_bridge\", False)","sourceCodeStart":4978,"sourceCodeEnd":5014,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/main.py#L4978-L5014","documentation":"Plain ValueError raised as the very first validation step of completion(): the model argument is None. Everything downstream (provider routing, auth, params) derives from the model string, so litellm refuses immediately instead of guessing.","triggerScenarios":"Calling litellm.completion(model=my_model, ...) where my_model is None -- typically a config key typo, an os.environ.get that returned None, or a dict lookup for the model name that missed.","commonSituations":"MODEL env var unset in one environment; config-driven model selection with a missing key; refactoring that renamed the variable holding the model but left the call with the old (empty) one; default argument chains ending in None.","solutions":["Pass a concrete model string, e.g. 'gpt-4o' or 'azure/my-deploy'","Find why the variable is None: print it / assert before the call -- usually a missing env var or config key","Add a default at the source: model = os.environ.get('MODEL') or 'gpt-4o-mini'","Guard the call site with a quick isinstance(model, str) and bool(model.strip()) check"],"exampleFix":"# before\nmodel = os.environ.get('MODEL_NAME')  # None when unset\nresp = litellm.completion(model=model, messages=m)  # ValueError: model param not passed in.\n\n# after\nmodel = os.environ.get('MODEL_NAME') or 'gpt-4o-mini'\nresp = litellm.completion(model=model, messages=m)","handlingStrategy":"type-guard","validationCode":"model = os.environ.get('MODEL') or DEFAULT_MODEL\nassert isinstance(model, str) and model.strip(), 'model must resolve to a non-empty string'","typeGuard":"from typing import TypeGuard, Any\n\ndef is_model_name(value: Any) -> TypeGuard[str]:\n    return isinstance(value, str) and bool(value.strip())","tryCatchPattern":"try:\n    resp = litellm.completion(model=model, messages=m)\nexcept ValueError as e:\n    if 'model param not passed in' in str(e):\n        raise RuntimeError('model resolution produced None; check config/env keys') from e\n    raise","preventionTips":["Never call completion with a possibly-None variable; default it first (os.environ.get('MODEL') or fallback)","Validate config-driven model fields with a schema (pydantic) that requires a non-empty string","Log the resolved model name at request start so None values are visible in traces","Centralize model selection in one function and unit-test it returns a valid string for every config path"],"tags":["validation","model-parameter","config","litellm"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}