{"record":{"id":"85b47a97d99bdb90","repo":"run-llama/llama_index","slug":"invalid-llm-name-llm-name","errorCode":null,"errorMessage":"Invalid LLM name: {llm_name}","messagePattern":"Invalid LLM name: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/llms/loading.py","lineNumber":44,"sourceCode":"    from llama_index.llms.huggingface_api import (\n        HuggingFaceInferenceAPI,\n    )  # pants: no-infer-dep\n\n    RECOGNIZED_LLMS[HuggingFaceInferenceAPI.class_name()] = HuggingFaceInferenceAPI\nexcept ImportError:\n    pass\n\n\ndef load_llm(data: dict) -> LLM:\n    \"\"\"Load LLM by name.\"\"\"\n    if isinstance(data, LLM):\n        return data\n    llm_name = data.get(\"class_name\")\n    if llm_name is None:\n        raise ValueError(\"LLM loading requires a class_name\")\n\n    if llm_name not in RECOGNIZED_LLMS:\n        raise ValueError(f\"Invalid LLM name: {llm_name}\")\n\n    return RECOGNIZED_LLMS[llm_name].from_dict(data)\n","sourceCodeStart":26,"sourceCodeEnd":47,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/llms/loading.py#L26-L47","documentation":"load_llm() found a class_name string but it is not a key in the RECOGNIZED_LLMS registry, which only contains core LLMs plus optional integrations (like HuggingFaceInferenceAPI) that registered themselves if their imports succeeded. The ValueError names the offending class so you can see exactly what string failed.","triggerScenarios":"Calling load_llm(data) where data['class_name'] is misspelled (e.g. 'openai' vs 'OpenAI'), refers to a third-party LLM class whose integration package is not installed (so it never registered), or refers to a custom LLM subclass that was never registered via RECOGNIZED_LLMS.","commonSituations":"Loading configs across environments where integration packages differ; class renamed between llama-index versions; custom LLM subclasses serialized on one machine and deserialized on another without the class registered.","solutions":["Check the exact registered name: from llama_index.core.llms.loading import RECOGNIZED_LLMS; print(RECOGNIZED_LLMS.keys()).","Install the missing integration package (e.g. pip install llama-index-llms-openai) so the class registers at import time.","For custom classes, import the class and assign RECOGNIZED_LLMS[MyLLM.class_name()] = MyLLM before load_llm.","Match casing exactly — registry keys are the class_name() strings, typically the class name."],"exampleFix":"# before\nllm = load_llm({\"class_name\": \"openai\", \"model\": \"gpt-4o\"})\n# after\nfrom llama_index.core.llms.loading import RECOGNIZED_LLMS\nassert \"OpenAI\" in RECOGNIZED_LLMS  # verify exact spelling\nllm = load_llm({\"class_name\": \"OpenAI\", \"model\": \"gpt-4o\"})","handlingStrategy":"validation","validationCode":"from llama_index.core.llms.loading import RECOGNIZED_LLMS\n\ndef is_recognized_llm_name(data: dict) -> bool:\n    return data.get(\"class_name\") in RECOGNIZED_LLMS","typeGuard":"def is_llm_payload(data) -> bool:\n    return hasattr(data, \"class_name\") or (isinstance(data, dict) and \"class_name\" in data)","tryCatchPattern":"try:\n    llm = load_llm(data)\nexcept ValueError as e:\n    if \"Invalid LLM name\" in str(e):\n        raise ValueError(\n            f\"{data.get('class_name')!r} not registered. \"\n            f\"Known: {sorted(RECOGNIZED_LLMS)}\"\n        ) from e\n    raise","preventionTips":["Check data['class_name'] against RECOGNIZED_LLMS keys before load_llm.","Install integration packages in every environment that loads their configs.","Register custom LLM classes in RECOGNIZED_LLMS before deserializing them."],"tags":["llama-index","serialization","registry","integration"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}