Google recently launched Gemini Code Assist – an AI code completion and assistance tool for enterprises – at the Cloud Next conference, which is currently underway in Las Vegas.

What is Gemini Code Assist? You can use Gemini Code Assist in your IDE, like VS Code, IntelliJ, Cloud Workstations, or Cloud Shell Editor to assist with the development, or use it in Google Cloud Console for assisted troubleshooting.

Gemini Code Assist can help you get code completions as you are writing the code, generate full functions or code blocks from comments, generate unit tests, and help you with debugging, understanding, and documenting your code.

Technically, it is an evolution of Duet AI, which Google discontinued a few months ago. However, now, it is more of a direct competitor to Microsoft's GitHub Copilot, which is one of the most prominent AI tools that can help you with coding.

Code Assist uses Gemini 1.5 Pro, which has a 1-million context window, the largest context window any model provides. This gives Code Assist a considerable edge. Users would even be able to perform changes to their entire code base with this context window, which no other platform currently offers.

Companies will also be able to fine-tune Code Assist to their internal code base, much like the GitHub Copilot.

You can try Gemini Code Assist for free till July 11, 2024, limited to one user per billing account.

For this guide, we'll be focusing on how you can use Gemini Code Assist in Visual Studio (VS) Code.

Setting Up Gemini Code Assist with VS Code

To use Code Assist with VS Code, you'll need to follow the steps below to set up the entire thing.

Install Cloud Code Extension

First of all, you need to install the Cloud Code extension to use Code Assist with VS Code.

  1. Open VS Code on your machine.
  2. Then, go to 'Extensions' from the left menu.
  1. Search for 'Cloud Code' using the search bar. Click on the first search result, i.e., Gemini + Google Cloud Code.
  1. Then, click on the 'Install' button and install the extension.

Cloud Code extension is now installed on VS Code. It works best with the following languages:

  • NodeJS
  • Go
  • Python
  • Java
  • .NET

While NodeJS has built-in support in VS Code and requires no additional action, you'll need to install the other languages if you want to use them. You can install these languages the same way you installed the Cloud Code extension.

Optionally, if you want to copy samples to your machine, you'll also need to install Git.

Connect to Google Cloud

Now, the next step involves connecting to Google Cloud from VS Code.

  1. Once the extension is installed, click on the 'Open Walkthrough' option.
  1. Click on the 'Connect' button on the 'Connect with Google Cloud' option.
  1. A message will appear that VS Code wants to open an external website. Click on 'Open' to proceed.
  1. Then, sign in to your Google account.
  2. Next, your Google account will ask you to make sure that you downloaded this app [Cloud Code] from Google; click on 'Sign in' to proceed.

Your account is now connected to Google Cloud.

Next, you'll need to activate Gemini in VS Code by selecting a Google Cloud project that has the Cloud API enabled. However, if you haven't signed up for Google Cloud till now, you'll first need to do that.

Sign Up for Google Cloud

If you don't have Google Cloud, you can get a free trial for 3 months with $300 credits.

  1. Go to and click on 'Get Started for Free'.
  1. Then, provide your account information and click on 'Agree & Continue'.
  1. Provide your payment information and click on 'Start Free' to get the free trial. You won't be charged after the trial ends unless you manually activate your full account for Google Cloud.

Once you have Google Cloud, you can use a project from it to use Gemini in VS Code.

Activate Gemini in VS Code

  1. Now, go back to VS Code and click on 'Select Google Cloud Project' to activate Gemini.
  1. The option to select the Google Cloud project will appear at the top. Select the Google Cloud Project with Cloud API enabled. You can also create a new Google Cloud Project.
  1. If Cloud API is not enabled for your selected project, you will receive an error on the VS Code window. Click on 'Enable API' to fix it.
  1. Gemini will be activated for use in VS Code. You can access it from the status bar at any time which will now show an activated Gemini, instead of the previous disabled Gemini icon (red icon with a diagonal line across it).
  1. The option for Gemini will also be added to the Activity Bar on the left.

That's it. Now, you can start using Gemini in VS Code to get help with code generation or chat with it.

Generating Code with Gemini

To use Gemini in VS Code, you can generate new code with prompts, get coding suggestions, or get in-line suggestions.

First, either open an existing application in which you want to use Gemini, or create a sample application for Cloud Code to test Gemini with.

  1. To create a sample application, press Ctrl + Shift + P (Windows/ Linux) or Cmd + Shift + P (Mac) to open the Command Pallete on VS Code.
  2. Then, type 'Cloud code: New application' and press Enter.
  1. Select 'Kubernetes application' from the options.
  1. Then, select a sample application from the options, like 'Python (Flask): Guestbook'. Note that you'll need to install the language you're installing the sample application in if you haven't already installed it.
  1. Save the application to your desired location, and the application will be created.

Once your application is created, create a new code file or open an existing one to use Gemini. Here's every way Gemini can help you with code generation.

Note: Gemini can produce incorrect code that seems plausible. Verify any output from Gemini before using it.

Get In-line Suggestions

  1. To get in-line suggestions, start typing your code.
  2. Gemini will provide you with auto-completing suggestions for your code as you write.
  3. You can press Tab to accept the suggestion. To ignore the suggestion, press Esc or keep writing the code.

Generate Code

  1. Gemini can also generate new code for you. Click the 'Gemini: Smart Actions' icon from the IDE window.
  1. Then, click 'Generate code' from the options.
  1. Gemini will generate new code for you based on the code already in your file.

Generate Code with Prompts

You can also provide prompts to Gemini to generate code for them.

  1. Go to a new line in your code and type # followed by the prompt for the code. For example, type # Function to create a Cloud Storage bucket and press Enter.
  1. Then, to generate code, press Ctrl + Enter whether you're on Windows, Linux, or Mac.
  2. Gemini will generate the code for your request. Press Tab on your keyboard to accept it.

Chat with Gemini

You can also chat with Gemini in VS Code. It can answer questions, explain the code to you, or help you with the selected code.

  1. To chat with Gemini, click the 'Gemini' icon from the Activity Bar on the left. The Gemini chat panel will open on the left.
  1. Type your prompt in the prompt bar and send it to the AI (your code file should be open for this). For example, you can say Explain this code to me. Gemini will use the code in your file as a reference and provide you with an explanation.
  1. You can also select the code in your file and then send the prompt to Gemini to explain the code. It will then only use the selected code as a reference while answering your query.
  1. You can also ask Gemini to generate unit tests for the entire code or the selected code in the chat panel. Type Generate unit tests in the chat panel and Gemini will generate unit tests for your entire code or selected functions (based on your selection).
  2. Similarly, you can ask Gemini to Help debug the code or Make the code more readable in the chat panel. Based on whether you selected a part of your code before prompting or not, it will come up with the desired response for part of your code/ entire code file.

Other Ways to Access Gemini

  1. You can also select code and perform an action using Gemini by clicking the 'Show Code Actions' icon (Bulb) from the code editor.
  1. You can also perform other actions with Gemini in VS Code. Open the Command Pallete on VS Code.
  2. Then, type 'Gemini:' and the options for how you can use Gemini will appear. You can ask Gemini to explain the code to you, focus on the chat view, generate code, generate unit tests, etc.

That's it. Gemini Code Assist is looking to be a great competitor to GitHub Copilot, especially with its 1 million context window. Now, the only thing left to see is if Gemini Code Assist will be as efficient at coding to actually become a useful tool.