ScrapeGraphAI/Scrapegraph-ai · error · ImportError
The langchain_together module is not installed.
Error message
The langchain_together module is not installed.
Please install it using `pip install langchain-together`. What it means
ImportError raised when model_provider is 'togetherai' but the langchain_together package is not installed in the environment. ScrapeGraphAI does not bundle every LangChain integration; Together AI support is an optional extra resolved lazily at LLM-creation time.
Source
Thrown at scrapegraphai/graphs/abstract_graph.py:281
if model_provider == "minimax":
return MiniMax(**llm_params)
if model_provider == "ernie":
from langchain_community.chat_models import ErnieBotChat
return ErnieBotChat(**llm_params)
elif model_provider == "oneapi":
return OneApi(**llm_params)
elif model_provider == "xai":
return XAI(**llm_params)
elif model_provider == "togetherai":
try:
from langchain_together import ChatTogether
except ImportError:
raise ImportError(
"""The langchain_together module is not installed.
Please install it using `pip install langchain-together`."""
)
return ChatTogether(**llm_params)
elif model_provider == "nvidia":
return Nvidia(**llm_params)
except Exception as e:
raise Exception(f"Error instancing model: {e}")
def get_state(self, key=None) -> dict:
""" ""
Get the final state of the graph.
Args:
key (str, optional): The key of the final state to retrieve.
View on GitHub (pinned to 532dfffbf6)
Solutions
- Install the package: pip install langchain-together (or uv add langchain-together / pip install 'scrapegraphai[togetherai]' if the extra exists).
- Pin a langchain-together version compatible with your installed langchain-core.
- Recreate/refresh the virtual environment and verify with 'python -c "from langchain_together import ChatTogether"'.
Example fix
# before (missing dep)
config = {'llm': {'model_provider': 'togetherai', 'api_key': key}}
# after
# shell: pip install langchain-together
config = {'llm': {'model_provider': 'togetherai', 'api_key': key}} Defensive patterns
Strategy: validation
Validate before calling
if config['llm'].get('model_provider') == 'togetherai':
import importlib.util
if importlib.util.find_spec('langchain_together') is None:
raise SystemExit('Run: pip install langchain-together') Type guard
def together_available() -> bool:
import importlib.util
return importlib.util.find_spec('langchain_together') is not None Try / catch
try:
graph = SmartScraperGraph(prompt=p, config=config)
except ImportError as e:
if 'langchain_together' in str(e):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'langchain-together'])
graph = SmartScraperGraph(prompt=p, config=config)
else:
raise Prevention
- Declare optional provider extras in requirements (langchain-together for togetherai).
- Probe packages with importlib.util.find_spec before graph construction.
- Use the same pinned dependency set in CI as locally.
When it happens
Trigger: config = {'llm': {'model_provider': 'togetherai', 'model': 'mixtral-8x7B-instruct-v0.1', 'api_key': ...}} on an environment where langchain-together is absent. Raised during graph __init__ -> _create_llm.
Common situations: Base install (pip install scrapegraphai) without extras; fresh CI environments; dependency pruning tools removing 'unused' optional packages; version mismatches after upgrading langchain.
Related errors
- The langchain_nvidia_ai_endpoints module is not installed.
- burr package is not installed. Please install
- scrapegraph_py is not installed. Install it with 'pip instal
- Model not supported
- module {__name__!r} has no attribute {name!r}
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/76851fa690b2a072.
Report an issue: GitHub.