Before you can use Gemini Code Assist, your team needs to perform the setup steps that are described in this document:
Optional: Purchase a subscription to Gemini Code Assist. Gemini Code Assist is available to try at no cost until November 8, 2024, limited to one user per billing account.
Enable the Gemini for Google Cloud API in a Google Cloud project. An administrator typically performs this step.
Grant Identity and Access Management (IAM) roles in a Google Cloud project. An administrator typically performs this step.
Install the Cloud Code plugin to use Gemini Code Assist in an IDE.
Optional: Purchase a Gemini Code Assist subscription
Gemini Code Assist is available to try without a subscription at no cost until November 8, 2024, limited to one user per billing account. Organizations with multiple users per billing account need to purchase a subscription as described in this section. If you have existing contracts with Google Cloud, contact our sales team before purchasing a subscription.
In the Google Cloud console, go to the Gemini for Google Cloud page.
The Gemini for Google Cloud page opens.
Select Gemini Code Assist.
The Gemini Code Assist panel is displayed.
Click Get Gemini Code Assist.
If asked, select a billing account, and then click Continue to Admin for Gemini page.
The Purchase Gemini Code Assist subscription page opens.
In Configure subscription, complete the fields to configure the subscription, including the commitment term (monthly or yearly) and the number of licenses in the subscription.
Choose whether you want to auto-renew your subscription after the commitment term (monthly or yearly). Auto-renew keeps your subscription and licenses active. If the subscription doesn't auto-renew, it ends when the current term ends, and you need to go through the purchase process again to regain the licenses.
To review the subscription details, click Continue.
If you agree to the terms, click Complete Purchase, and then confirm your subscription.
Billing is now enabled for Gemini. You now need to enable the Gemini for Google Cloud API in one or more projects that are associated with this billing account. Users won't see Gemini until you activate it in at least one project.
Enable the Gemini for Google Cloud API in a Google Cloud project
This section describes the steps required to enable the Gemini for Google Cloud API in a Google Cloud project.
Console
To enable the Gemini for Google Cloud API, go to the Gemini for Google Cloud page.
In the project selector, select a project.
Click Enable.
The page updates and shows a status of Enabled. Gemini is now available in the selected Google Cloud project to all users who have the required IAM roles.
gcloud
-
In the Google Cloud console, activate Cloud Shell.
In the project selector menu, select a project.
Enable the Gemini for Google Cloud API for Gemini using the
gcloud services enable
command:gcloud services enable cloudaicompanion.googleapis.com
If you want to enable the Gemini for Google Cloud API in a different Google Cloud project, add the
--project
parameter:gcloud services enable cloudaicompanion.googleapis.com --project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project ID.The output is similar to the following:
Waiting for async operation operations/acf.2e2fcfce-8327-4984-9040-a67777082687 to complete... Operation finished successfully.
Gemini for Google Cloud is now available in the specified Google Cloud project to all users who have the required IAM roles.
Grant IAM roles in a Google Cloud project
This section describes the steps required to grant the Gemini for Google Cloud User and Service Usage Consumer IAM roles to users.
Console
To grant the IAM roles that are required to use Gemini, go to the IAM & Admin page.
In the Principal column, find a principal for which you want to enable access to Gemini, and then click Edit principal in that row.
In the Edit access pane, click
Add another role.In Select a role, select Gemini for Google Cloud User.
Click Add another role and select Service Usage Consumer.
Click Save.
gcloud
-
In the Google Cloud console, activate Cloud Shell.
In the project selector menu, select a project.
Grant the Gemini for Google Cloud User role:
gcloud projects add-iam-policy-binding PROJECT_ID \ --member=PRINCIPAL --role=roles/cloudaicompanion.user
Replace
PRINCIPAL
with the identifier for the principal. The identifier takes the formuser|group|serviceAccount:email
ordomain:domain
—for example,user:[email protected]
,group:[email protected]
,serviceAccount:[email protected]
, ordomain:example.domain.com
.The output is a list of policy bindings that includes the following:
- members: - user:PRINCIPAL role: roles/cloudaicompanion.user
Grant the Service Usage Consumer role:
gcloud projects add-iam-policy-binding PROJECT_ID \ --member=PRINCIPAL --role=roles/serviceusage.serviceUsageConsumer
The output is a list of policy bindings that includes the following:
- members: - user:PRINCIPAL role: roles/serviceusage.serviceUsageConsumer
For more information, see
Grant a single role
and
gcloud projects add-iam-policy-binding
.
All of the users who have been granted these roles can access Gemini for Google Cloud features in the Google Cloud console within the specified project. For more information, see Gemini for Google Cloud overview.
Install the Cloud Code plugin to use Gemini Code Assist in an IDE
If you're a developer who wants to use Gemini in your IDE, then you need to install the Cloud Code plugin. For more information, see the following:
- Cloud Workstations: Code with Gemini Code Assist
- Cloud Shell Editor: Code with Gemini Code Assist
- Cloud Code for VS Code: Code with Gemini Code Assist
- Cloud Code for IntelliJ and other JetBrains IDEs: Code with Gemini Code Assist
Advanced setup tasks
Instead of using the Google Cloud console or the gcloud CLI to grant predefined IAM roles, you can do any of the following:
Use IAM REST APIs or IAM client libraries to grant roles.
If you use these interfaces, use the fully qualified role names:
roles/cloudaicompanion.user
roles/serviceusage.serviceUsageConsumer
For more information about granting roles, see Manage access to projects, folders, and organizations.
Create and grant custom roles.
Any custom roles that you create need the following permissions to access Gemini:
cloudaicompanion.companions.generateChat
cloudaicompanion.companions.generateCode
cloudaicompanion.instances.completeCode
cloudaicompanion.instances.completeTask
cloudaicompanion.instances.generateCode
cloudaicompanion.instances.generateText
serviceusage.services.use
What's next
- Learn more about the types of generative AI assistance available in Gemini for Google Cloud.
- Learn how Gemini for Google Cloud uses your data.
- Learn how to access and manage Gemini admin controls.