This is an extension to quickly query OpenAI's ChatGPT (both GPT-3.5 and GPT-4) from VS Code. A ChatGPT Plus subcription is not required to use this extension.
GPT-3.5, which powers ChatGPT, is a large language model made by OpenAI. The official GPT-3.5 API costs $0.002 / 1K tokens for both prompts and responses, where 1,000 tokens is approximately 750 words, so $1 would buy approximately 375,000 words.
Alternatively, you can opt to use GPT-4, GPT-3.5's successor, which is an even more powerful model. The API is currently invite-only, however you can sign up for the waitlist here. The API is more expensive than GPT-3.5, costing $0.03 / 1K tokens for prompts and $0.06 / 1K tokens for responses, meaning $1 would buy approximately 12,500 words of prompts and 6,250 words of response..
To use this extension, you must provide an OpenAI API token linked to an account with billing set up; costs for using the API are charged directly to your OpenAI account.
- Select the code you want to ask about. If you want to ask about the whole file, do not select any text.
- Right click inside the editor and select
ChatGPT: Ask why code isn't working
. - Wait for the response. It will appear in a new tab.
- Select the code you want to ask about. If you want to ask about the whole file, do not select any text.
- Right click inside the editor and select
ChatGPT: Ask to explain code
. - Wait for the response. It will appear in a new tab.
Use the "ChatGPT: Ask a question" command in the Command Palette:
- Press
Ctrl
+Shift
+P
to open the Command Palette. - Begin typing
ChatGPT: Ask a question
, and select it when it appears. - Enter the question you'd like to ask.
- Wait for the response. It will appear in a new tab.
When you first query ChatGPT, you will be prompted to enter an OpenAI API key. This is used by the extension to access the API and is only sent to OpenAI.
To find your OpenAI API key:
- Go to https://platform.openai.com/account/api-keys. You will need to log in (or sign up) to your OpenAI account.
- Click "Create new secret key", and copy it.
- You should then paste it into VS Code when prompted.
You must also have billing set up on your OpenAI account (see Pricing below).
Once your OpenAI API key has been set you can update it using the "ChatGPT: Change OpenAI API key" command in the Command Palette:
- Press
Ctrl
+Shift
+P
to open the Command Palette. - Begin typing
ChatGPT: Change OpenAI API key
, and select it when it appears. - Enter your OpenAI API key (see above instructions on how to find).
The GPT-3.5 API is charged by OpenAI at $0.002 / 1K tokens, while the GPT-4 API comes at $0.03 / 1K tokens. This is charged directly to your OpenAI account. To use this extension, you must set up billing on your account. Find more info about pricing at https://openai.com/pricing#chat.
In order to switch the model between GPT-3.5 (default) and GPT-4:
Ctrl
+,
to open Preferences.- Search for
chatgpt-helper.model
. - Use the dropdown to switch between GPT-3.5 and GPT-4.