This is an extension to quickly query OpenAI's Codex, an AI code assistant similar to ChatGPT, from VS Code.
Note
Temporarily, the extension is using Codex, a similar model by OpenAI, instead of ChatGPT, since ChatGPT is near impossible to automate at this time.
- 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 Codex, 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. Codex is currently free, so does not use up any credits on your account.
To find your OpenAI API key:
- Go to https://beta.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.
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).
In order to change the message sent to the AI that comes before your code, when running the Ask ChatGPT about your code
, follow these instructions:
Ctrl
+,
to open Preferences.- Search for
chatgpt
. - Change the
chatgpt.queryText
setting to whatever you want.
None