ScrapeGraphAI/Scrapegraph-ai · error · ValueError
Could not determine model name from llm_model. Please specif
Error message
Could not determine model name from llm_model. Please specify 'model' in batch_config.
What it means
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.
Source
Thrown at scrapegraphai/nodes/batch_generate_answer_node.py:95
self.batch_model = batch_config.get("model")
self.batch_temperature = batch_config.get("temperature", 0.0)
def _get_model_name(self) -> str:
"""Extract the OpenAI model name from the LLM configuration.
Returns:
The model name string (e.g., 'gpt-4o-mini').
"""
if self.batch_model:
return self.batch_model
# Try to extract model name from the LangChain model instance
if hasattr(self.llm_model, "model_name"):
return self.llm_model.model_name
if hasattr(self.llm_model, "model"):
return self.llm_model.model
raise ValueError(
"Could not determine model name from llm_model. "
"Please specify 'model' in batch_config."
)
def _get_format_instructions(self) -> str:
"""Get format instructions based on the schema configuration."""
if self.schema is not None:
output_parser = get_pydantic_output_parser(self.schema)
return output_parser.get_format_instructions()
return (
"You must respond with a JSON object. Your response should be "
"formatted as a valid JSON with a 'content' field containing "
'your analysis. For example:\n'
'{"content": "your analysis here"}'
)
def _build_prompt_text(
self,View on GitHub (pinned to 532dfffbf6)
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
Example fix
# before
node = BatchGenerateAnswerNode(node_config={'batch_config': {}})
# after
node = BatchGenerateAnswerNode(
node_config={'batch_config': {'model': 'gpt-4o-mini'}}
) Defensive patterns
Strategy: validation
Validate before calling
def model_name_available(llm) -> bool:
return hasattr(llm, 'model_name') or hasattr(llm, 'model')
# or just set it explicitly:
node_config = {'batch_config': {'model': 'gpt-4o-mini'}} Type guard
from typing import Protocol
class NamedModel(Protocol):
model_name: str
def has_model_name(m) -> bool:
return hasattr(m, 'model_name') or hasattr(m, 'model') Try / catch
try:
name = node._get_model_name()
except ValueError:
node.node_config.setdefault('batch_config', {})['model'] = 'gpt-4o-mini' Prevention
- Always set batch_config.model when using non-standard model wrappers
- Pin known LangChain integration versions
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No parsed documents found in state
- Response took longer than {timeout} seconds
- Model not supported
- model_tokens not specified
- Provider {llm_params["model_provider"]} is not supported.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/9f2e041cf44ffb0b.
Report an issue: GitHub.