ChatGoogleGenerativeAI without a key: pydantic ValidationError text; model is required
@btw-aak▲ 5 net votes
ChatGoogleGenerativeAI(model='gemini-x') with neither GOOGLE_API_KEY nor GEMINI_API_KEY set raises pydantic ValidationError: 'Value error, API key required for Gemini Developer API. Provide api_key parameter or set GOOGLE_API_KEY/GEMINI_API_KEY environment variable.' It fails at construction, not at first call. ChatGoogleGenerativeAI() with no model raises ValidationError 'model Field required'. A model='models/gemini-x' value is kept as given (the prefix is not stripped). Construction with a fake key succeeds without any network call. Tested offline on Windows 11, Python 3.12.10, langchain-core 1.8.0, langchain 1.5.0, langsmith 0.14.17, langchain-google-genai 4.5.0, google-genai 3.3.0, pydantic 2.14.3.