@anvia/gemini

中文文档
1.1.10发布于 2026/11/04MITTypeScriptES Module构建来源已验证近 30 天下载 2775

Gemini provider adapter for Anvia.

原始使用文档
文档目录4 节
  1. Install
  2. Quickstart
  3. What you can build
  4. Learn more

@anvia/gemini

Run Anvia agents and retrieval workflows with Gemini. Connect through the Gemini API or Vertex AI using the same provider-neutral agent interfaces.

Install

pnpm add @anvia/gemini @anvia/core

Quickstart

Set GEMINI_API_KEY before running this example.

import { Agent } from "@anvia/core";
import { GeminiClient } from "@anvia/gemini";

const client = new GeminiClient({
  apiKey: process.env.GEMINI_API_KEY!,
});
const agent = new Agent({
  id: "assistant",
  model: client.completionModel({ modelId: "gemini-3.7-flash" }),
  instructions: "Answer clearly and concisely.",
});

const result = await agent.generate({
  prompt: "What should I check before launching a new product?",
});

if (result.type === "response") {
  console.log(result.output);
}

What you can build

  • Streaming completions, tools, structured output, and typed reasoning controls.
  • Embeddings with configurable task type and dimensions.
  • Image generation through Gemini native models or Imagen.
  • Transcription, model listing, and Vertex AI authentication.

For Vertex AI, pass vertexAi: { projectId, location } instead of apiKey. The usage guide includes authentication and image API selection.

Learn more

版本与发布记录

@anvia/gemini 共发布 65 个版本,首次发布于 2026/05/03;过去 12 个月发布了 65 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.10latest2026/11/043 天前
1.1.92026/10/2711 天前
1.1.82026/10/1523 天前
1.1.72026/10/051 个月前
1.1.62026/09/251 个月前
1.1.42026/09/151 个月前

其他发布通道:preview → 0.2.10-preview.20260628T094557.2ab9488,rc → 1.0.0-rc.11。

关于 @anvia/gemini 的常见问题

@anvia/gemini 是什么?

Gemini provider adapter for Anvia.

如何安装 @anvia/gemini?

在项目目录运行 npm install @anvia/gemini,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@anvia/core(^1.17.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anvia/gemini 支持 TypeScript 吗?

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

@anvia/gemini 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@anvia/gemini 可以商用吗?

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

@anvia/gemini 的下载量有多少?

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

@anvia/gemini 还在维护吗?

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