Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-01。"],[],[],null,["# Chat about your notebook with Gemini\n====================================\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document describes how you can use\nGemini in Colab Enterprise, which is a product\nin the [Gemini for Google Cloud](/gemini/docs/overview) portfolio,\nto chat about your notebook.\n\nLearn [how and when Gemini\nfor Google Cloud uses your data](/gemini/docs/discover/data-governance).\n\nThis document is intended for data analysts, data scientists, and\ndata developers who work with Colab Enterprise. It assumes you have\nknowledge of how to write code in a notebook environment.\n\nOverview\n--------\n\nYou can chat with Gemini about potential coding solutions or\nhow to do specific tasks in your notebook. You can also get explanations of the\ncode in a notebook.\n\nFor example, you might start with prompts similar to the following:\n\n- How do I filter a Pandas DataFrame?\n- How can I create a plot in Colab Enterprise?\n- Show me a list of publicly available datasets.\n- Summarize the purpose of this notebook.\n\nGemini uses your notebook as context. You can discuss relevant\ndetails, get suggestions for improving your code, or get ideas for what to\ntry next.\n\nBefore you begin\n----------------\n\n| As an early-stage technology, Gemini for Google Cloud\n| products can generate output that seems plausible but is factually incorrect. We recommend that you\n| validate all output from Gemini for Google Cloud products before you use it.\n| For more information, see\n| [Gemini for Google Cloud and responsible AI](/gemini/docs/discover/responsible-ai).\n\n1. [Ensure that\n Gemini in Colab Enterprise is set up for your\n Google Cloud user account and project.](/gemini/docs/colab/set-up-gemini)\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n-\n\n\n Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com, cloudaicompanion.googleapis.com, dataform.googleapis.com, compute.googleapis.com)\n\n-\n\n\n Enable the Vertex AI, Cloud AI Companion, Dataform, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com, cloudaicompanion.googleapis.com, dataform.googleapis.com, compute.googleapis.com)\n\n### Required roles\n\n\nTo get the permissions that\nyou need to use Gemini in Colab Enterprise,\n\nask your administrator to grant you the\nfollowing IAM roles on the project:\n\n- [Colab Enterprise User](/iam/docs/roles-permissions/aiplatform#aiplatform.colabEnterpriseUser) (`roles/aiplatform.colabEnterpriseUser`)\n- [Gemini for Google Cloud User](/iam/docs/roles-permissions/cloudaicompanion#cloudaicompanion.user) (`roles/cloudaicompanion.user`)\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n| One or more of the required roles includes the `dataform.repositories.list` permission. Users who are granted the `dataform.repositories.list` permission or the [Code Creator\n| (`roles/dataform.codeCreator`)](/iam/docs/understanding-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.\n\nUse chat\n--------\n\nTo chat about your notebook with Gemini, do the following:\n\n1. In the Google Cloud console, go to\n the Colab Enterprise **My notebooks** page.\n\n [Go to My notebooks](https://console.cloud.google.com/vertex-ai/colab/notebooks)\n2. In the **Region** menu, select the region that contains your notebook.\n\n3. Click the notebook that you want to open.\n\n4. In the toolbar, click the\n spark **Gemini**\n button to open the chat dialog.\n\n5. In the **Gemini** dialog, enter a prompt to begin\n your chat.\n\n6. Gemini responds to your prompt. The response can\n include code snippets, general advice for your notebook, or general\n information that might help answer your question.\n\n After evaluating the content, you can do the following:\n - To copy a suggested code snippet, click the **Copy** button. Then paste the code into a code cell in your notebook.\n - To add a suggested code snippet as a new code cell in your notebook, click the **Add\n code cell** button.\n - Ask follow-up questions and continue the discussion as needed.\n7. To close the **Gemini** dialog, click\n close **Close**.\n\nTurn off Gemini in Colab Enterprise\n-----------------------------------\n\n\nTo turn off Gemini in Colab Enterprise for a\nGoogle Cloud project, an administrator must turn off the\nGemini for Google Cloud API. See\n[Disabling services](/service-usage/docs/enable-disable#disabling).\n\n\nTo turn off Gemini in Colab Enterprise for a specific user, an\nadministrator needs to revoke the\n[Gemini for\nGoogle Cloud User](/iam/docs/understanding-roles#cloudaicompanion.user) (`roles/cloudaicompanion.user`) role for that user. See\n[Revoke\na single IAM role](/iam/docs/granting-changing-revoking-access#revoke-single-role).\n\nWhat's next\n-----------\n\n- Read the [Gemini for Google Cloud\n overview](/gemini/docs/overview).\n\n- For more ways to write and edit code with Gemini\n assistance, see the following:\n\n - [Use code completion and code generation](/colab/docs/use-code-completion)\n - [Explain code cells](/colab/docs/explain-cells)\n - [Explain and fix errors](/colab/docs/explain-errors)\n - [Use the Data Science Agent](/colab/docs/use-data-science-agent)\n- Learn [how Gemini for Google Cloud uses\n your data](/gemini/docs/discover/data-governance)."]]