BerriAI/litellm · error · Exception
Importing google.generativeai failed, please run 'pip instal
Error message
Importing google.generativeai failed, please run 'pip install -q google-generativeai
What it means
Error "Importing google.generativeai failed, please run 'pip install -q google-generativeai" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/deprecated_providers/palm.py:104
}
def completion(
model: str,
messages: list,
model_response: ModelResponse,
print_verbose: Callable,
api_key,
encoding,
logging_obj,
optional_params: dict,
litellm_params=None,
logger_fn=None,
):
try:
import google.generativeai as palm
except Exception:
raise Exception("Importing google.generativeai failed, please run 'pip install -q google-generativeai")
palm.configure(api_key=api_key)
model = model
## Load Config
inference_params: Final = copy.deepcopy(optional_params)
inference_params.pop(
"stream", None
) # palm does not support streaming, so we handle this by fake streaming in main.py
config: Final = litellm.PalmConfig.get_config()
for k, v in config.items():
if (
k not in inference_params
): # completion(top_k=3) > palm_config(top_k=3) <- allows for dynamic variables to be passed in
inference_params[k] = v
prompt = ""
for message in messages:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Install google-generativeai: pip install -q google-generativeai.
When it happens
Trigger: Thrown at litellm/llms/deprecated_providers/palm.py:104 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/22781d32b38f0242.
Report an issue: GitHub.