
Security News
Socket Security Analysis Is Now One Click Away on npm
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.
@langchain/google-vertexai
Advanced tools
This package contains resources to access Google AI/ML models and other Google services via Vertex AI. Authorization to these services use service account credentials stored on the local file system or provided through the Google Cloud Platform environment it is running on.
If you are running this on a platform where the credentials cannot be provided this way, consider using the @langchain/google-vertexai-web package instead. You do not need to use both packages. See the section on Authorization below.
$ pnpm install @langchain/google-vertexai
Authorization is done through a Google Cloud Service Account.
To handle service accounts, this package uses the google-auth-library
package, and you may wish to consult the documentation for that library
about how it does so. But in short, classes in this package will use
credentials from the first of the following that apply:
apiKey attributeauthInfo attributeAPI_KEYGOOGLE_APPLICATION_CREDENTIALS environment
variable.gcloud auth application-default login, then the
default credentials.When using tools with Gemini models through Vertex AI, be aware of the following Zod schema limitations:
Discriminated Unions - .discriminatedUnion() is not supported
// ❌ This will throw an error
z.discriminatedUnion("type", [
z.object({ type: z.literal("a"), value: z.string() }),
z.object({ type: z.literal("b"), value: z.number() }),
]);
// ✅ Use a flat object with optional fields instead
z.object({
type: z.enum(["a", "b"]),
stringValue: z.string().optional(),
numberValue: z.number().optional(),
});
Union Types - z.union() is not supported
// ❌ This will throw an error
z.union([z.string(), z.number()]);
// ✅ Consider using separate optional fields
z.object({
stringValue: z.string().optional(),
numberValue: z.number().optional(),
});
Positive Refinement - .positive() is automatically converted
// ⚠️ This is automatically converted to .min(0.01)
z.number().positive();
// ✅ Prefer using .min() directly
z.number().min(0.01);
If you use unsupported schema features, you'll receive descriptive error messages:
"Gemini cannot handle union types (discriminatedUnion, anyOf, oneOf)""Failed to convert tool '[toolName]' schema for Gemini".min() instead of .positive() for number constraintsFAQs
LangChain.js support for Google Vertex AI
The npm package @langchain/google-vertexai receives a total of 340,213 weekly downloads. As such, @langchain/google-vertexai popularity was classified as popular.
We found that @langchain/google-vertexai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.