Become a Code Ninja with CodeGPT VSCode Extension
Tags: api, vscode, chatgpt, automation
Published: 2023-01-26 18:34:42



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wnk40nzb9wy7sc9v2vc.png)


**Code GPT** is a powerful and versatile extension for Visual Studio Code (VSCode) that allows developers to generate code snippets and complete blocks of code using the GPT-3 natural language processing model. This extension is incredibly helpful for developers who are working on complex projects, as it allows them to quickly generate code snippets that are tailored to their specific needs.



> Important!​
> The CodeGPT extension is FREE but the APIs of artificial intelligence provider OpenAI API that it consumes is a paid service. You get $18 free credit as part of free trial usage.

## About OpenAI API​

To use this extension, you must have credits loaded into your OpenAI account. This extension uses the Official OpenAI API, which is a paid API.

Prices can be found at this link: https://openai.com/api/pricing/

> If you do not have credits, the extension will show the following OpenAI API `error: You exceeded your current quota, please check your plan and billing details`

To review your account and the credits you have available, you must log in with your account at https://openai.com/api

In the menu select Manage Account, then in the Usage section, you will be able to see the amount of credits available and used.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zh4580x2lrbjdjqhn697.png)


In this image you can see that $0.05 USD has been used out of $18 as part of free trial usage.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grgerj1jzr5kevglk3q3.png)


## Installation

Install Visual Studio Code: Visual Studio Code: https://code.visualstudio.com/download

Download and install the Code GPT Extension from the below link, or search in the Extensions tab in VSCode: https://marketplace.visualstudio.com/items?itemName=DanielSanMedium.dscodegpt

**Open VSCode and go to the Extensions tab**
The first step in adding Code GPT to VSCode is to open the code editor and go to the Extensions tab. This tab can be accessed by clicking on the Extensions icon on the left sidebar or by pressing the keyboard shortcut Ctrl+Shift+X.

**Search for Code GPT**
Once you are in the Extensions tab, use the search bar to search for Code GPT. You should see the extension listed in the search results.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr96sp0984p9axypz1zf.png)



**Install Code GPT**
Once you have located the Code GPT extension, click on the Install button to begin the installation process. The installation process may take a few seconds, depending on your internet connection.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcgey8wv13xoi54rh86q.png)



**Get your API key​ from OpenAI​:**

1. Create an account in openai.com
2. Go to View API Keys
3. Create a new Secret Key​

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cidn19b4r8z64tjsrrpq.png)


**Use your API KEY​**
Press cmd + shift + p and search for `CodeGPT: Set API KEY`

Copy the secret key and press enter

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnvmsswtegkc6gdtxeqd.png)


**To Remove your API KEY (not required now)​**
If you want to remove your API Key to add a new one, press cmd + shift + p and search for CodeGPT: Remove API KEY


## Start using Code GPT

Once you have configured the extension, you can start using Code GPT to generate code snippets and complete blocks of code. To do this, simply type in a natural language description of the code you want to generate and press the Code GPT icon in the status bar. The extension will then generate the code snippet or block of code that matches your description.

**Get code from comments**
Write a comment asking for a specific code
Press `cmd + shift + i`
Use the code 😎


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9uvkeb9jk7b7cshrt1q.gif)



**Create a README.md with `Ask CodeGPT`**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sw64xexb6vm9pppbs4zm.gif)


## Conclusion
In conclusion, adding Code GPT as an extension to VSCode is a simple and straightforward process that can greatly enhance your coding experience. With the ability to generate code snippets and complete blocks of code using natural language, this extension can save you time and effort while working on complex projects. Give it a try and see how it can help you in your coding journey!

To start with ChatGPT directly from the browser, register and start here (currently free with limitations): https://chat.openai.com/chat

Read more about ChatGPT in this blog: https://dev.to/aws-heroes/chatgpt-the-power-and-pitfalls-of-a-leading-language-model-3n39