Use code completion and code generation Skip to main content
Stay organized with collections Save and categorize content based on your preferences.
Use code completion and code generationThis document describes how you can use Gemini in Colab Enterprise, which is a product in the Gemini for Google Cloud portfolio, to help you write and generate code in a Colab Enterprise notebook.
Learn how and when Gemini for Google Cloud uses your data.
This document is intended for data analysts, data scientists, and data developers who work with Colab Enterprise. It assumes you have knowledge of how to write code in a notebook environment.
Before you beginAs an early-stage technology, Gemini for Google Cloud products can generate output that seems plausible but is factually incorrect. We recommend that you validate all output from Gemini for Google Cloud products before you use it. For more information, see Gemini for Google Cloud and responsible AI.
Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.
Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.
To get the permissions that you need to use Gemini in Colab Enterprise, ask your administrator to grant you the following IAM roles on the project:
roles/aiplatform.colabEnterpriseUser
)roles/cloudaicompanion.user
)For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
One or more of the required roles includes thedataform.repositories.list
permission. Users who are granted the dataform.repositories.list
permission or the Code Creator (roles/dataform.codeCreator
) role in a project can list the names of code assets in that project by using the Dataform API or the Dataform command-line interface (CLI). Non-administrators using BigQuery Studio can only see code assets that they created or that were shared with them. Enable code completion and code generation
To enable code completion and code generation, do the following:
In the Google Cloud console, go to the Colab Enterprise My notebooks page.
In the toolbar, click the pen_spark Help me code button and select the features that you want to use.
If the pen_spark Help me code button isn't active, or if you don't see a list of features when you click the button, see Set up Gemini in Colab Enterprise for a project.
To use code completion in a Colab Enterprise notebook, do the following:
In the Google Cloud console, go to the Colab Enterprise My notebooks page.
In the Region menu, select the region that contains your notebook.
Click the notebook that you want to open.
In a code cell of your notebook, start entering code. Colab Enterprise suggests a potential way to complete your code in gray italic text.
For example, if you enter import p
, Colab Enterprise might suggest a code completion that imports pandas as pd
followed by a line that reads a CSV file and stores the contents in a pandas dataframe.
To accept the suggested code completion, press Tab.
To generate code using Gemini for Google Cloud:
In the Google Cloud console, go to the Colab Enterprise My notebooks page.
In the Region menu, select the region that contains your notebook.
Click the notebook that you want to open.
In the toolbar, click the pen_spark Help me code button and select Code generation if it isn't already selected.
In your notebook, add a blank code cell, or click a code cell that doesn't have any code in it.
Click spark Available AI features, and then click Generate code.
In the pen_spark Generate field, type a description of the code that you want to generate, and then press Enter.
To close the Generate panel, click Close.
To turn off code completion and code generation, do the following:
In the Colab Enterprise toolbar, click the pen_spark Help me code button.
Clear the features that you want to turn off.
This section shows you how to resolve issues with using Gemini in Colab Enterprise.
Gemini features not workingWhen you type in a Colab Enterprise notebook, code completion suggestions don't appear. Or, the pen_spark Help me code button doesn't appear above a code cell.
In your Colab Enterprise settings, you might have turned off the Show context-powered code completions setting.
To resolve this issue, do the following:
Read the Gemini for Google Cloud overview.
For more ways to write and edit code with Gemini assistance, see the following:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This guide explains how to use Gemini in Colab Enterprise to assist with writing code within a notebook environment, including code completion and generation."],["To utilize Gemini's features, you must have the appropriate IAM roles assigned to your user account, specifically the Colab Enterprise User and Gemini for Google Cloud User roles."],["Gemini offers code completion, which suggests code snippets as you type, and code generation, which creates code based on descriptions you provide, along with a feature to fix errors in your existing code."],["Gemini features can be turned on or off via the \"Help me code\" button in the Colab Enterprise toolbar, which also allows you to select or deselect the features you wish to utilize."],["If Gemini features are not working, ensure that the \"Show context-powered code completions\" setting is enabled in the Colab Enterprise editor settings."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4