如需使用 Gemini on Gemini Enterprise Agent Platform,您需要使用 Cloud de Confiance by S3NS API 密钥或应用默认凭证进行身份验证。我们建议使用 API 密钥进行测试,并使用应用默认凭证进行生产。本页面介绍了如何配置应用默认凭据。
准备工作
选择项目、启用结算功能、启用 Agent Platform API、安装 gcloud CLI
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
创建本地身份验证凭证
控制台
为您的用户账号创建本地身份验证凭证:
gcloud auth application-default login
如果返回身份验证错误,请确认您已 使用联合身份登录 gcloud CLI。
curl
运行以下命令以安装并运行 gcloud 来设置应用默认凭证:
bash <(curl -sSL https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.sh)发出您的第一个 API 请求
配置应用默认凭证后,请参阅 API 快速入门,了解如何发出第一个请求。