Chatgpt in VScode

Sharing is caring!

Last Updated on March 22, 2023 by Jay

Are you tired of endlessly searching for coding answers in your Internet browser? If you’re like me, you probably have hundreds of tabs open with various Stack Overflow and tutorial pages. In this article, we’ll show you how to use the CodeGPT plugin for Visual Studio Code. This plugin allows you to access the power of ChatGPT directly in your VScode editor. You can ask ChatGPT to generate code, explain code, and even write documentation—all within VSCode. No more going back and forth between windows! Let’s dive in.

Installing the CodeGPT Plugin in VS Code

chatgpt in vscode

The plugin’s name is “CodeGPT”, to install it:

  1. In VS Code, click on the extension button to go to the Extension Marketplace.
  2. Search for “CodeGPT.”
  3. Find the plugin called “CodeGPT” with the publisher name “”
  4. Install the plugin (if you haven’t already).

This plugin is free to use and connects to ChatGPT via an API. You’ll need an API key from OpenAI.

Obtaining Your OpenAI API Key

To get your API key from OpenAI, follow these steps:

  1. Go to the OpenAI website and register for a free account.
  2. After registering, you’ll have a $5 free trial credit.
  3. In your OpenAI account, click on your profile and view API keys.
  4. Click on the button to create a new secret key, and make sure to copy the key before clicking away.
  5. Use the “Copy” button to copy the key, as you won’t be able to see it again once you navigate away from the page.
getting free openai API key

If you ever lose your secret key, you can simply return to this page and create a new one.

Setting Up the CodeGPT Plugin in VS Code

After installing the plugin and obtaining your API key, follow these steps to set up the CodeGPT plugin in VS Code:

  1. Press Ctrl+Shift+P to bring up the Command Palette.
  2. Type “Set API Key” and select the “CodeGPT: Set API Key” option.
  3. Paste the API key you copied from OpenAI and press Enter to confirm.

I recommend reloading VS Code after installing the plugin. You can change the settings by clicking on the gear icon and going to “Extension Settings.”

CodeGPT uses OpenAI as the provider by default, and the default language model is GPT-3.5-turbo. You can also choose GPT-4 from the list, but you’ll need to request access from OpenAI first.

codegpt settings

How to Use CodeGPT in VS Code

There are several ways to access and interact with CodeGPT in VS Code. We’ll go through all of them:

  1. Use the CodeGPT plugin window: Click on the CodeGPT icon in the left side panel to bring up the plugin chat window. From here, you can communicate with ChatGPT.
codegpt chat windows inside vscode

2. Use comments: Type a comment in your code as a prompt, then press Ctrl+Shift+I to send the prompt to ChatGPT.

3. Use the context menu: Select code in your editor, right-click to bring up the menu, and choose from the available CodeGPT options.

The plugin is smart enough to know that the “selected code” refers to the code in your editor, and it can generate, explain, or modify the code as needed.

Cost of Running CodeGPT Models

API usage & cost

Although the $5 free trial credit may not sound like much, it can actually last you a long time. To give you an idea of the cost of running these models using the API, let’s look at an example:

During my experimentation on March 19th, I made API 32 requests. On March 21st, I made another 8 requests, bringing the total to 40 requests. The total cost for these requests was only about 4 cents. As you can see, the $5 credit can indeed last for an extended period, depending on your usage.

Wrapping Up

The CodeGPT plugin for Visual Studio Code brings the power of ChatGPT directly into your editor, streamlining your workflow and reducing the need to switch between windows. With the ability to generate code, explain code, and write documentation, this plugin can save you time and enhance your productivity. Give it a try and discover the benefits of integrating ChatGPT into your development process.

We hope this article has provided you with helpful insights on how to install, set up, and use the CodeGPT plugin in Visual Studio Code. Thank you for reading, and happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *