Become a Code Expert with CodeGPT VSCode Extension
Tags: visualstudiocode, vscodeextentions, vscode, chatgpt
Published: 2023-02-13 07:24:01

In this article, we will learn how to configure the CodeGPT extension in VSCode and its use cases.

### What is CodeGPT?
CodeGPT VSCode Extension is a plugin for the popular code editor, Visual Studio Code (VSCode), that utilizes OpenAI's language model to provide advanced code completion functionality. The extension integrates directly into VSCode, providing real-time code suggestions as you type. Using advanced machine learning algorithms, CodeGPT VSCode Extension can understand the context of your code and provide suggestions that are relevant to your current coding task. This can help you save time and improve your coding efficiency by reducing the time spent searching for the right code snippets. CodeGPT VSCode Extension is designed to make coding faster, more efficient, and more enjoyable for VSCode users.

### Features of CodeGPT
- Ask general questions 
- Right click on a code selection and run one of the context menu shortcuts
    - Automatically write documentation for your code
    - Explain the selected code
    - Refactor or optimize it
    - Find problems with it
- View GPT's responses in a panel next to the editor

### Install Extension
1. Go to extensions menu on VSCode and search for `Code GPT` then Install it.
![Install-CodeGPT](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mbjbizy9tebrj8puoi1p.png)

## Retrieve OpenAI API Key
1. Go to [OpenAI's website](https://beta.openai.com/account/api-keys). If you don't have an account, you will need to create one or sign up using your Google or Microsoft account.
2. Click on the `Create new secret key` button.
![Create-ChatGPT-API-Key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9oxa8a31zwxu96m21v4.png)
3. Your API key is generated copy it as shown in the image below:
![API-Key-Generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/874iewzm8arzrkxeird2.png)

    ***NOTE**: When you create a new account, you receive $18 in free credits for the API which you must use in the first 90 days. You can see API usage information [here](https://platform.openai.com/account/usage).

## Configure API Key in CodeGPT
Now, the final step is to put this secret key in the settings of VSCode extension Code GPT. By perform the following steps:
- Press ```Ctrl+Shift+P``` 
- Search for `CodeGPT: Set API KEY`
- Finally, insert the Key and press `Enter` as shown in the image below:
![Configure-API-Key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tffri7404l66und6glwg.png)

## Ready to Use
- Select any code, open the context menu with the right mouse button, and choose the desired option from the list:
    - `Ask CodeGPT`: will provide a prompt for you to enter any query
    - `Compile & Run CodeGPT`
    - `Explain CodeGPT`
    - `Refactor CodeGPT`
    - `Document CodeGPT`
    - `Find Problems CodeGPT`
    - `Unit Test CodeGPT`
![Commands-CodeGPT](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gu9qo85gknk4xydmmdgd.png)
- See the result of ChatGPT's answer in a new editor window.
- You can see more features [here](https://www.codegpt.co/docs/category/features).

Thanks for reading!!!☺