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