Use OpenAI’s models inside Visual Studio Code
- o3-mini
- o1
- o1-mini
- GPT-4o
- GPT-4o-mini
- GPT-4-Turbo
- GPT-3.5-Turbo
- Set your API key.
- Highlight a question or code snippet in the editor (or use the entire file).
- Open the Command Palette (
Cmd + Shift + P
on macOS,Ctrl + Shift + P
on Windows/Linux). - Type "Ask GPT".
GPT’s response can either replace the highlighted text or open in a new file, depending on your Output Mode.
- Get an API key from OpenAI's website.
- Go to Dashboard → API Keys.
- Click "Create new secret key" and copy it.
- Press
Cmd + Shift + P
(macOS) orCtrl + Shift + P
(Windows/Linux). - Search for "GPT: Set API Key" and paste your key.
- Command:
Ask GPT
- Shortcut:
Alt + Shift + I
- Usage:
- Highlight code or text.
- Run Ask GPT.
- GPT replies with the answer in a new document or replaces the selected text (based on Output Mode).
- Command:
Ask GPT with File
- Usage:
- Sends the entire file contents to GPT instead of just highlighted text.
- Command:
GPT: Export Chat History
- Usage:
- Exports your entire conversation to a Markdown file—useful for sharing or later reference.
- Command:
GPT: Show Chat History
- Usage:
- Displays your multi‑turn conversation as a Markdown document in a new pane.
- Command:
GPT: Clear Chat History
- Usage:
- Resets the entire conversation context, wiping all previous Q&A turns.
- Command:
GPT: Change Model
- Usage:
- Pick from available models (
o1
,GPT-4-Turbo
, etc.). - Subsequent requests use the chosen model.
- Pick from available models (
- Command:
GPT: Change Token Limit
- Usage:
- Sets how many tokens GPT can return (up to each model’s maximum).
- Command:
GPT: Change Temperature
- Usage:
- Adjusts GPT’s “creativity” from
0.0
(deterministic) to1.0
(more freeform).
- Adjusts GPT’s “creativity” from
- Command:
GPT: Change TopP
- Usage:
- Limits GPT to top‑probability tokens from
0.0
–1.0
. - Higher values allow more diverse tokens.
- Limits GPT to top‑probability tokens from
- Command:
GPT: Change Context Mode
- Options:
- No Context – Ignores all previous messages, each query is single‑turn.
- Last N Messages – Considers only the most recent N turns from the conversation.
- Full – Considers the entire conversation for each new request.
- Usage:
- Ideal for switching between single question/answer usage and deeper, multi‑turn conversation.
- Command:
GPT: Set Context Length
- Usage:
- If Last N Messages context mode is active, specify how many recent messages GPT considers.
- Command:
GPT: Change Output Mode
- Usage:
- Toggles between "Replace Selection" or "New File".
- In “Replace Selection” mode, GPT’s response overwrites the text you highlighted.
- In “New File” mode, GPT’s response opens in a fresh editor tab.
- Command:
GPT: Change Debug Mode
- Usage:
- Shows or hides detailed logs in the GPT Debug output channel for troubleshooting.
- Flexible Conversation Context: Choose no context, the last N messages, or the entire session for each query.
- Error & Rate Limit Handling: Clear messages for invalid keys, missing model, or rate limits.
- Cross‑Language Support: Works for code or text in any language recognized by VSCode.
- API Key Storage: Securely stores your API key in VSCode’s global state.
- Conversation Context Modes:
- No Context, Last N Messages, or Full conversation reference.
- Set Context Length for Last N mode.
- Support for latest models (
o3-mini
). - Change temperature and top_p settings.
- Export chat history to a Markdown file.
- Insert response as comment in your code.
- Support for newest models (
o1
, etc.). - Improved chat history and advanced error handling.
- Keyboard shortcut (
Alt + Shift + I
).
- Added newer models (
o1-preview
,o1-mini
). - Enhanced error/debug messages.
- Introduced debug mode (logs in
GPT Debug
panel). - Switched to axios for HTTP requests.
- Removed Davinci (deprecated).
- Added GPT‑4o model.
- Added GPT‑4‑Turbo model.
- API keys saved securely across sessions.
- Removed shared API Key usage.
- Compatible with VSCode 1.7+.
- Basic multi‑turn chat.
- Added GPT‑4.
- Handled errors for shared API key usage.
- Invalid Key: Double‑check at OpenAI’s API Keys.
- Rate Limits: If usage is too high, wait or check your OpenAI usage dashboard.
- Debugging: Toggle "GPT: Change Debug Mode" to see request logs in GPT Debug.
MIT License – Open‑source for flexibility and contributions.
Happy Coding & Prompting!