设置项目和开发环境

为帮助您开始使用 Gemini Enterprise Agent Platform,本页面将引导您完成以下操作:创建 Google Cloud 项目并启用 Agent Platform API。如果您没有执行这些任务的权限,请让管理员为您设置项目并启用 Gemini Enterprise Agent Platform。本页面还介绍了如何在本地开发环境中设置 Google Cloud CLI。

设置项目

如需设置项目,请按以下步骤操作:

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请 创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Gemini Enterprise Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Gemini Enterprise Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

设置身份验证

    选择标签页以了解您打算如何访问 API:

    控制台

    当您使用 Google Cloud 控制台访问 Google Cloud 服务和 API 时,无需设置身份验证。

    gcloud

    1. 安装 Google Cloud CLI。

    2. 如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

    3. 如需初始化 gcloud CLI,请运行以下命令:

      gcloud init
    4. 初始化 gcloud CLI 后,对其进行更新并安装所需组件:

      gcloud components update
      gcloud components install beta

    如需设置 gcloud CLI 以使用服务账号模拟(而不是您的用户凭据)向 Google API 进行身份验证,请运行以下命令:

    gcloud config set auth/impersonate_service_account SERVICE_ACCT_EMAIL

    如需了解详情,请参阅服务账号模拟

    客户端库

    如需在本地开发环境中使用客户端库,请安装并初始化 gcloud CLI,然后使用您的用户凭证设置应用默认凭证。

    1. 安装 Google Cloud CLI。

    2. 如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

    3. 初始化 gcloud CLI 后,对其进行更新并安装所需组件:

      gcloud components update
      gcloud components install beta
    4. 如果您使用的是本地 shell,请为您的用户账号创建本地身份验证凭证:

      gcloud auth application-default login

      如果您使用的是 Cloud Shell,则无需执行此操作。

      如果系统返回身份验证错误,并且您使用的是外部身份提供方 (IdP),请确认您已 使用联合身份登录 gcloud CLI

    如需了解详情,请参阅 Google Cloud 身份验证文档中的 为本地开发环境设置 ADC

    如需设置本地 ADC 文件以使用服务账号模拟(而不是您的用户凭据)向 Google API 进行身份验证,请运行以下命令:

    gcloud auth application-default login --impersonate-service-account=SERVICE_ACCT_EMAIL

    如需了解详情,请参阅服务账号模拟

    REST

    如需在本地开发环境中使用 REST API,请使用您提供给 gcloud CLI 的凭证。

    1. 安装 Google Cloud CLI。

    2. 如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

    3. 初始化 gcloud CLI 后,对其进行更新并安装所需组件:

      gcloud components update
      gcloud components install beta

    如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证

    您可以使用服务账号模拟为 REST API 请求生成访问令牌。如需了解详情,请参阅模拟的服务账号

    如需了解如何为生产环境设置身份验证,请参阅 Google Cloud 身份验证文档中的 为在 Google Cloud上运行的代码设置应用默认凭据

让管理员为您设置 Gemini Enterprise Agent Platform 项目

本部分介绍了管理员如何授予使用 Gemini Enterprise Agent Platform 所需的角色。

  1. 确定有意义的项目名称和项目 ID,以便标识您的项目。 如果您属于某个组织或计划创建多个项目,请考虑需遵循或可以遵循哪些命名惯例和文件夹层次结构,以使项目组织清晰。
  2. 所需的角色:
    1. 大多数 Gemini Enterprise Agent Platform 功能的访问权限由 Gemini Enterprise Agent Platform User (roles/aiplatform.user) IAM 角色授予,并且应足以满足大多数 Gemini Enterprise Agent Platform 用户的需求。如需完全控制 Gemini Enterprise Agent Platform 资源,您可以请求 Gemini Enterprise Agent Platform Administrator (roles/aiplatform.admin) 角色。如需了解这些角色与其他 Gemini Enterprise Agent Platform 角色之间的区别,请参阅使用 IAM 进行 Gemini Enterprise Agent Platform 访问权限控制
    2. 如果您还打算在 Google Cloud中使用 Gemini Enterprise Agent Platform Workbench 实例,请让管理员为您授予项目的 Notebooks Administrator (roles/notebooks.admin) IAM 角色,以及项目或 Compute Engine 默认服务账号Service Account User (roles/iam.serviceAccountUser) IAM 角色。
    3. 此外,如需启用必要的 API,您需要 Service Usage Admin (roles/serviceusage.serviceUsageAdmin) IAM 角色,或者您的管理员需要按照前几个步骤为您启用 API。
  3. 请让管理员为您启用 Agent Platform API。 如果您已获得 Service Usage Admin (roles/serviceusage.serviceUsageAdmin) IAM 角色,则将能够自行执行此操作。

后续步骤