# @core-ai/google-vertex 中文文档

规范地址：https://npmcn.com/package/%40core-ai/google-vertex/

版本：0\.38\.0
npm 元数据更新时间：2026-11-06T13:59:22.567Z
中文译文更新时间：2026-11-10T18:49:47.544Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40core-ai/google-vertex
原文对照：https://npmcn.com/package/%40core-ai/google-vertex/?lang=original
项目主页：https://github.com/agdevhq/core-ai#readme
源码仓库：https://github.com/agdevhq/core-ai

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：9.2 kB，5 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2026-07-15T01:26:45.704Z
- 最新版本发布：2026-11-06T13:59:21.920Z
- 近 30 天下载量：4319（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 30 个）

## 中文简介

Vertex 大赦国际 @core-ai/core-ai的谷歌供应商包

## 安装

```sh
npm install @core-ai/google-vertex
```

也可以使用：`pnpm add @core-ai/google-vertex`、`yarn add @core-ai/google-vertex`、`bun add @core-ai/google-vertex`

## README

# @ core-ai/ google- 顶点

[![npm](https://img.shields.io/npm/v/@core-ai/google-vertex.svg)](https://www.npmjs.com/package/@core-ai/google-vertex)

Vertex AI供应商软件包上的谷歌 `@core-ai/core-ai`它使用 [`@google/genai`](https://www.npmjs.com/package/@google/genai) vertex AI模式中的客户端并共享聊天、嵌入、图像生成、结构化输出和推理行为 `@core-ai/google-genai`。 。 。 .

## 安装

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

## 使用量

```ts
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);
```

## 认证

默认情况下,提供者使用 [Google 应用程序默认证书( ADC)](https://cloud.google.com/docs/authentication/application-default-credentials)数字 :

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

用明确的服务账户认证, 解析其 JSON 密钥, 并将其传递为 `credentials`数字 :

```ts
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),
});
```

您也可以输入预配置 `GoogleGenAI` 客户端 :

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

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

## 模式和区域

将 Vertex AI 型号ID 传到相应的型号工厂:

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

模型提供情况因区域而异。 一个供应商实例针对一个区域,因此在不同地点托管模型时创建单独的供应商.

## 图像生成

```ts
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);
```

双子座图像模型使用本土多模式生成并返回基础64图像 数据.

## 供应商的选择和能力

这个提供者分享其模式行为 `@core-ai/google-genai`选项 `google`。 。 。 . `@core-ai/google-vertex` 再导出适用的提供者-选项计划、能力助手和推理元数据类型.

## 常见问题

### @core-ai/google-vertex 是什么？

Vertex 大赦国际 @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 和提交记录判断。

