Langchain has the new class GoogleGenerativeAI which lets us use API keys from the AI Studio! We no longer have to create an SA and authenticate via SA impersonation.
That being said, we need to update the credentials.
Remove all instances of regular "VertexAI" and replace with the appropriate langchain_google_genai classes like GoogleGenerativeAI or GoogleGenerativeAIEmbeddings
Remove instances of using the SA via env variables and PROJECT ID declarations
Have a method for storing and retrieving the API key securely such as the .env file
Langchain has the new class
GoogleGenerativeAI
which lets us use API keys from the AI Studio! We no longer have to create an SA and authenticate via SA impersonation.That being said, we need to update the credentials.
langchain_google_genai
classes likeGoogleGenerativeAI
orGoogleGenerativeAIEmbeddings