Google Gen AI 库

本页面提供有关下载和安装 Gemini API 最新库的信息。如果您刚开始使用 Gemini API,请先参阅 API 快速入门

关于 google-genai 库的重要说明

我们最近推出了一组新库,可让您在不同的 Google 服务中以更一致、更简化的方式访问 Google 的生成式 AI 模型。

Gemini Enterprise Agent Platform 库仅在 Gemini Enterprise Agent Platform 上受支持。

主要库更新

语言 Gemini Enterprise Agent Platform 库 新库(推荐)
Python google-cloud-aiplatform
GenerativeModel 模块将于 2026 年 5 月弃用
google-genai
Go cloud.google.com/vertexai
将于 2026 年 5 月弃用
google.golang.org/genai
JavaScript 和 TypeScript @google-cloud/vertexai
将于 2026 年 5 月弃用
@google/genai
目前为预览版
Java google-cloud-vertexai
将于 2026 年 5 月弃用
java-genai
目前为预览版
.NET Google.Cloud.AIPlatform.V1
将于 2026 年 5 月弃用
Google.GenAI
目前为预览版

建议用户从新库开始,并从之前的库进行迁移。

安装库

以下示例可帮助您开始使用各种编程语言。

运行以下命令安装我们的 Python 库

    pip install google-genai