Fosowl/agenticSeek · error · ImportError
litellm is not installed. Install with: pip install litellm
Error message
litellm is not installed. Install with: pip install litellm
What it means
litellm_fn imports the litellm package lazily; if the import fails it raises ImportError telling you to install it with pip. LiteLLM is an optional dependency used as a gateway to 100+ LLM providers, so the library does not ship it as a hard requirement.
Source
Thrown at sources/llm_provider.py:519
except CloudflareError as e:
raise CloudflareError(f"Cloudflare protection encountered: {str(e)}") from e
except NetworkError as e:
raise NetworkError("Network error occurred. Check your internet connection.") from e
except APIError as e:
raise APIError(f"API error occurred: {str(e)}") from e
return None
def litellm_fn(self, history, verbose=False):
"""
Use LiteLLM AI gateway for completion.
Routes to 100+ providers (OpenAI, Anthropic, Azure, Bedrock,
Vertex AI, Groq, Together, Ollama, etc.) based on model prefix.
See https://docs.litellm.ai/docs/providers
"""
try:
import litellm
except ImportError as e:
raise ImportError("litellm is not installed. Install with: pip install litellm") from e
if self.is_local:
raise Exception("LiteLLM is not available for local use. Change config.ini")
api_key = os.getenv("LITELLM_API_KEY", None)
try:
call_kwargs = {
"model": self.model,
"messages": history,
"drop_params": True,
}
if api_key:
call_kwargs["api_key"] = api_key
response = litellm.completion(**call_kwargs)
if response is None:
raise Exception("LiteLLM response is empty.")
thought = response.choices[0].message.contentView on GitHub (pinned to ae57a23577)
Solutions
- Run `pip install litellm` (or add it to your requirements/pyproject) in the active environment
- Confirm the interpreter/venv running the app is the one where you installed it (which python; pip show litellm)
- If install fails, check Python version compatibility and resolve conflicting dependencies
Example fix
// before
# litellm not installed -> ImportError at call time
thought = provider.litellm_fn(history)
// after
# terminal
pip install litellm
# then in code
try:
thought = provider.litellm_fn(history)
except ImportError:
thought = provider.test_fn(history) Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec('litellm') is None:
raise SystemExit('litellm missing. Run: pip install litellm') Try / catch
try:
thought = provider.litellm_fn(history)
except ImportError:
logger.error('Install litellm: pip install litellm')
raise Prevention
- Add litellm to requirements.txt/pyproject dependencies
- Install inside the same venv/container that runs the app
- Smoke-test `import litellm` in CI before running provider code
- Ensure your IDE/notebook kernel uses the environment where you installed it
When it happens
Trigger: Calling LLMProvider.litellm_fn(history) (directly or via the provider-selection layer) in an environment where `import litellm` raises ImportError — package never installed, installed in a different venv, or optional deps missing.
Common situations: Fresh clone without optional extras installed; running inside a venv/container that lacks the package; dependency conflict where pip skipped litellm; notebook kernel pointing at another interpreter.
Related errors
- {str(e)} A import related to provider {self.provider_name} w
- LiteLLM is not available for local use. Change config.ini
- LiteLLM response is empty.
- LiteLLM API error: {str(e)}
AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30).
Data as JSON: /api/errors/4c460e5ee49808d3.
Report an issue: GitHub.