@core-ai/google-vertex

中文文档
0.38.0发布于 2026/11/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 4319

Vertex AI Google provider package for @core-ai/core-ai

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Authentication
  4. Models and regions
  5. Image generation
  6. Provider options and capabilities

@core-ai/google-vertex

npm

Google on Vertex AI provider package for @core-ai/core-ai. It uses the @google/genai client in Vertex AI mode and shares chat, embedding, image generation, structured-output, and reasoning behavior with @core-ai/google-genai.

Installation

npm install @core-ai/core-ai @core-ai/google-vertex zod

Usage

import { generate } from '@core-ai/core-ai';
import { createGoogleVertex } from '@core-ai/google-vertex';

const googleVertex = createGoogleVertex({
    projectId: process.env.GOOGLE_VERTEX_PROJECT,
    region: 'europe-west1',
});
const model = googleVertex.chatModel('gemini-2.5-flash');

const result = await generate({
    model,
    messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(result.content);

Authentication

By default, the provider uses Google Application Default Credentials (ADC):

const googleVertex = createGoogleVertex({
    projectId: process.env.GOOGLE_VERTEX_PROJECT,
    region: 'europe-west1',
});

To authenticate with an explicit service account, parse its JSON key and pass it as credentials:

const rawCredentials = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON;
const credentialsJson = rawCredentials?.trim().startsWith('{')
    ? rawCredentials
    : Buffer.from(rawCredentials ?? '', 'base64').toString('utf8');

const googleVertex = createGoogleVertex({
    projectId: process.env.GOOGLE_VERTEX_PROJECT,
    region: 'europe-west1',
    credentials: JSON.parse(credentialsJson),
});

You can also inject a preconfigured GoogleGenAI client:

import { GoogleGenAI } from '@google/genai';

const googleVertex = createGoogleVertex({
    client: new GoogleGenAI({
        vertexai: true,
        project: 'my-project',
        location: 'europe-west1',
    }),
});

Models and regions

Pass Vertex AI model IDs to the corresponding model factory:

const chat = googleVertex.chatModel('gemini-2.5-flash');
const embeddings = googleVertex.embeddingModel('gemini-embedding-001');
const image = googleVertex.imageModel('gemini-2.5-flash-image');

Model availability varies by region. A provider instance targets one region, so create separate providers when models are hosted in different locations.

Image generation

import { generateImage } from '@core-ai/core-ai';

const result = await generateImage({
    model: googleVertex.imageModel('gemini-2.5-flash-image'),
    prompt: 'A watercolor robot in a mountain cabin at sunrise',
    size: '1024x1024',
});

console.log(result.images[0]?.base64);

Gemini image models use native multimodal generation and return base64 image data.

Provider options and capabilities

This provider shares its model behavior with @core-ai/google-genai. Provider options remain namespaced under google. @core-ai/google-vertex re-exports the applicable provider-option schemas, capability helpers, and reasoning metadata types.

版本与发布记录

@core-ai/google-vertex 共发布 30 个版本,首次发布于 2026/07/15;过去 12 个月发布了 30 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.38.0latest2026/11/064 天前
0.37.02026/11/055 天前
0.36.22026/10/2912 天前
0.36.12026/10/2813 天前
0.36.02026/10/2219 天前
0.35.02026/10/1427 天前

关于 @core-ai/google-vertex 的常见问题

@core-ai/google-vertex 是什么?

Vertex AI Google provider package for @core-ai/core-ai

如何安装 @core-ai/google-vertex?

在项目目录运行 npm install @core-ai/google-vertex,或使用 pnpm add / yarn add / bun add。

@core-ai/google-vertex 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@core-ai/google-vertex 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@core-ai/google-vertex 可以商用吗?

@core-ai/google-vertex 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@core-ai/google-vertex 的下载量有多少?

根据 npm 官方下载统计,@core-ai/google-vertex 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,319 次,日均约 144 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@core-ai/google-vertex 还在维护吗?

最新版本 0.38.0 发布于 2026/11/06(4 天前);至今共发布 30 个版本,其中过去 12 个月发布了 30 个;首次发布于 2026/07/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。