{"record":{"id":"9f2e041cf44ffb0b","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"could-not-determine-model-name-from-llm-model-ple","errorCode":null,"errorMessage":"Could not determine model name from llm_model. Please specify 'model' in batch_config.","messagePattern":"Could not determine model name from llm_model\\. Please specify 'model' in batch_config\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/nodes/batch_generate_answer_node.py","lineNumber":95,"sourceCode":"        self.batch_model = batch_config.get(\"model\")\n        self.batch_temperature = batch_config.get(\"temperature\", 0.0)\n\n    def _get_model_name(self) -> str:\n        \"\"\"Extract the OpenAI model name from the LLM configuration.\n\n        Returns:\n            The model name string (e.g., 'gpt-4o-mini').\n        \"\"\"\n        if self.batch_model:\n            return self.batch_model\n\n        # Try to extract model name from the LangChain model instance\n        if hasattr(self.llm_model, \"model_name\"):\n            return self.llm_model.model_name\n        if hasattr(self.llm_model, \"model\"):\n            return self.llm_model.model\n\n        raise ValueError(\n            \"Could not determine model name from llm_model. \"\n            \"Please specify 'model' in batch_config.\"\n        )\n\n    def _get_format_instructions(self) -> str:\n        \"\"\"Get format instructions based on the schema configuration.\"\"\"\n        if self.schema is not None:\n            output_parser = get_pydantic_output_parser(self.schema)\n            return output_parser.get_format_instructions()\n        return (\n            \"You must respond with a JSON object. Your response should be \"\n            \"formatted as a valid JSON with a 'content' field containing \"\n            'your analysis. For example:\\n'\n            '{\"content\": \"your analysis here\"}'\n        )\n\n    def _build_prompt_text(\n        self,","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/nodes/batch_generate_answer_node.py#L77-L113","documentation":"BatchGenerateAnswerNode._get_model_name tries to read the model name from the LangChain model instance via 'model_name' then 'model' attributes; if neither exists it raises this error telling you to set 'model' explicitly in batch_config. This name is needed to build batch API requests.","triggerScenarios":"Passing an llm_model wrapper that exposes neither .model_name nor .model (some third-party/custom LangChain integrations); constructing the node with a client object instead of a chat model instance.","commonSituations":"Using a newer LangChain integration that renamed the attribute; passing Azure/other providers whose attribute naming differs; forgetting to set batch_config={'model': ...} when using an exotic model.","solutions":["Set the model name explicitly in node config: node_config={'batch_config': {'model': 'gpt-4o-mini'}}","Check dir(llm_model) to see which attribute holds the model name and use a model class that exposes model_name or model","Subclass BatchGenerateAnswerNode and override _get_model_name for custom model wrappers"],"exampleFix":"# before\nnode = BatchGenerateAnswerNode(node_config={'batch_config': {}})\n# after\nnode = BatchGenerateAnswerNode(\n    node_config={'batch_config': {'model': 'gpt-4o-mini'}}\n)","handlingStrategy":"validation","validationCode":"def model_name_available(llm) -> bool:\n    return hasattr(llm, 'model_name') or hasattr(llm, 'model')\n\n# or just set it explicitly:\nnode_config = {'batch_config': {'model': 'gpt-4o-mini'}}","typeGuard":"from typing import Protocol\nclass NamedModel(Protocol):\n    model_name: str\n\ndef has_model_name(m) -> bool:\n    return hasattr(m, 'model_name') or hasattr(m, 'model')","tryCatchPattern":"try:\n    name = node._get_model_name()\nexcept ValueError:\n    node.node_config.setdefault('batch_config', {})['model'] = 'gpt-4o-mini'","preventionTips":["Always set batch_config.model when using non-standard model wrappers","Pin known LangChain integration versions"],"tags":["scrapegraphai","batch","model-config","llm"],"backgroundTag":"missing-config-option","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}