{"record":{"id":"4c460e5ee49808d3","repo":"Fosowl/agenticSeek","slug":"litellm-is-not-installed-install-with-pip-instal","errorCode":null,"errorMessage":"litellm is not installed. Install with: pip install litellm","messagePattern":"litellm is not installed\\. Install with: pip install litellm","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"sources/llm_provider.py","lineNumber":519,"sourceCode":"        except CloudflareError as e:\n            raise CloudflareError(f\"Cloudflare protection encountered: {str(e)}\") from e\n        except NetworkError as e:\n            raise NetworkError(\"Network error occurred. Check your internet connection.\") from e\n        except APIError as e:\n            raise APIError(f\"API error occurred: {str(e)}\") from e\n        return None\n\n    def litellm_fn(self, history, verbose=False):\n        \"\"\"\n        Use LiteLLM AI gateway for completion.\n        Routes to 100+ providers (OpenAI, Anthropic, Azure, Bedrock,\n        Vertex AI, Groq, Together, Ollama, etc.) based on model prefix.\n        See https://docs.litellm.ai/docs/providers\n        \"\"\"\n        try:\n            import litellm\n        except ImportError as e:\n            raise ImportError(\"litellm is not installed. Install with: pip install litellm\") from e\n\n        if self.is_local:\n            raise Exception(\"LiteLLM is not available for local use. Change config.ini\")\n\n        api_key = os.getenv(\"LITELLM_API_KEY\", None)\n\n        try:\n            call_kwargs = {\n                \"model\": self.model,\n                \"messages\": history,\n                \"drop_params\": True,\n            }\n            if api_key:\n                call_kwargs[\"api_key\"] = api_key\n            response = litellm.completion(**call_kwargs)\n            if response is None:\n                raise Exception(\"LiteLLM response is empty.\")\n            thought = response.choices[0].message.content","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/llm_provider.py#L501-L537","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n# litellm not installed -> ImportError at call time\nthought = provider.litellm_fn(history)\n// after\n# terminal\npip install litellm\n# then in code\ntry:\n    thought = provider.litellm_fn(history)\nexcept ImportError:\n    thought = provider.test_fn(history)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec('litellm') is None:\n    raise SystemExit('litellm missing. Run: pip install litellm')","typeGuard":null,"tryCatchPattern":"try:\n    thought = provider.litellm_fn(history)\nexcept ImportError:\n    logger.error('Install litellm: pip install litellm')\n    raise","preventionTips":["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"],"tags":["missing-dependency","import-error","litellm","installation"],"backgroundTag":"module-not-installed","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}