{"record":{"id":"09ae3c3bb4cb86b7","repo":"BerriAI/litellm","slug":"model-not-set","errorCode":null,"errorMessage":"model not set","messagePattern":"model not set","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/main.py","lineNumber":8379,"sourceCode":"    litellm_logging_obj: Final = Logging(\n        model=\"\",\n        messages=[],\n        stream=False,\n        call_type=\"acompletion\",\n        litellm_call_id=str(uuid.uuid4()),\n        start_time=datetime.datetime.now(),\n        function_id=str(uuid.uuid4()),\n        log_raw_request_response=True,\n    )\n    model_params[\"litellm_logging_obj\"] = litellm_logging_obj\n    model_params = HealthCheckHelpers._update_model_params_with_health_check_tracking_information(\n        model_params=model_params\n    )\n    #########################################################\n    try:\n        model: str | None = model_params.get(\"model\", None)\n        if model is None:\n            raise Exception(\"model not set\")\n\n        if model in litellm.model_cost and mode is None:\n            mode = litellm.model_cost[model].get(\"mode\")\n\n        custom_llm_provider_from_params: Final = model_params.get(\"custom_llm_provider\", None)\n        api_base_from_params: Final = model_params.get(\"api_base\", None)\n        api_key_from_params: Final = model_params.get(\"api_key\", None)\n\n        model, custom_llm_provider, _, _ = get_llm_provider(\n            model=model,\n            custom_llm_provider=custom_llm_provider_from_params,\n            api_base=api_base_from_params,\n            api_key=api_key_from_params,\n        )\n        if model in litellm.model_cost and mode is None:\n            mode = litellm.model_cost[model].get(\"mode\")\n\n        model_params[\"cache\"] = {\"no-cache\": True}  # don't used cached responses for making health check calls","sourceCodeStart":8361,"sourceCodeEnd":8397,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/main.py#L8361-L8397","documentation":"ahealth_check() runs a real minimal call against the model described in model_params; the first thing it does is read model_params.get('model'). When the key is missing or None it raises Exception('model not set') before doing anything else.","triggerScenarios":"await litellm.ahealth_check({'messages': [{'role': 'user', 'content': 'hi'}]}) — a params dict without 'model'; model loaded from config where the key is absent; model resolved to None dynamically.","commonSituations":"Health-check wiring copied from completion() calls that pass model as a separate argument; proxy config templates missing the model field; optional config keys defaulting to None.","solutions":["Include the model key: await litellm.ahealth_check({'model': 'openai/gpt-4o-mini', 'messages': [...]})","Validate the params dict has a truthy 'model' before calling","In proxy deployments, make sure the model exists in config so the check receives it"],"exampleFix":"# before\nawait litellm.ahealth_check({\"messages\": [{\"role\": \"user\", \"content\": \"hi\"}]})\n\n# after\nawait litellm.ahealth_check({\"model\": \"openai/gpt-4o-mini\", \"messages\": [{\"role\": \"user\", \"content\": \"hi\"}]})","handlingStrategy":"validation","validationCode":"if not model_params.get(\"model\"):\n    raise ValueError(\"health check requires model_params['model']\")\nresult = await litellm.ahealth_check(model_params)","typeGuard":null,"tryCatchPattern":"try:\n    result = await litellm.ahealth_check(model_params)\nexcept Exception as e:\n    if \"model not set\" in str(e):\n        raise RuntimeError(\"health-check params missing 'model'\") from e\n    raise","preventionTips":["Build health-check params from the same validated config as real calls","Assert required keys on any params dict crossing an API boundary"],"tags":["litellm","health-check","model","required-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}