How to Set Up ChatGPT Codex in VS Code (Step by Step)
Codex is OpenAI’s coding agent. In VS Code you use the official extension (Marketplace ID openai.chatgpt). You can also run the Codex CLI in a terminal. Sign in with your ChatGPT account.
In short: install Codex – OpenAI’s coding agent, open the Codex sidebar, sign in with ChatGPT, then chat beside your code or hand bigger jobs to cloud tasks when your plan allows. Optional: install the Codex CLI for the same account in a terminal.
Why Codex in VS Code
If you already pay for ChatGPT, Codex is the coding agent that sits in your editor: open files and selections become context, you review diffs in place, and you can keep longer work in the same account.
What the product is called (Oct 2026)
- VS Code extension: Marketplace title: Codex – OpenAI’s coding agent. Extension ID:
openai.chatgpt. - Codex CLI: Terminal agent. Official installers include a curl script from chatgpt.com/codex and package options shown in OpenAI docs.
- ChatGPT sign-in: Codex is included across ChatGPT plans (including Free/Go on current Help Center wording); usage limits vary. Re-check chatgpt.com/pricing.
- Codex Cloud: Longer cloud tasks — Help Center says availability depends on plan (often Plus/Pro/Business/Edu/Enterprise). Not the same as Free/Go IDE chat.
- macOS ChatGPT app: On Mac, the extension can also connect “Work with VS Code” from the ChatGPT desktop app for simple Q&A/edits.
How setup flows
Install steps (VS Code)
- Open VS Code. Press Ctrl+Shift+X (Mac: Cmd+Shift+X).
- Search Codex / OpenAI and install Codex – OpenAI’s coding agent (publisher OpenAI, ID
openai.chatgpt). - Or from Quick Open (Ctrl+P):
ext install openai.chatgpt. - Open a project folder.
- Click the Codex icon in the Activity Bar / side panel. If missing: Command Palette → Codex: Open Codex Sidebar.
- Sign in with your ChatGPT account and finish the browser flow.
- Many people drag the Codex panel to the right side so chat sits next to the editor.
Optional: Codex CLI
- Follow the current install command on OpenAI’s Codex CLI docs (macOS/Linux often:
curl -fsSL https://chatgpt.com/codex/install.sh | sh— re-check the docs if the URL changes). - cd into your project and run
codex. - Sign in with ChatGPT when prompted.
- Useful slash-style commands (names can change): status, model, permissions, review, init for an agents file — run
?or help inside the CLI.
Settings and configuration
- Model / effort: pick from the Codex UI or CLI model controls. Exact labels change; choose a coding-capable model for hard tasks.
- Permissions / sandbox: keep approvals on for shell and file writes until you trust the task.
- Config file: CLI/extension share user config under
~/.codex/config.toml(Windows:%USERPROFILE%\.codex\config.toml). - Old approval_policy: if Codex fails to start mentioning
approval_policy = "untrusted", remove that setting (OpenAI removed it in newer builds). - Project rules: add a short
AGENTS.md(Codex/initcan create one) so standing rules are not retyped.
# Project rules for Codex - Language: TypeScript (strict) or Python 3.12 as marked in the folder - Tests must pass before you finish a task - Prefer small diffs; do not rewrite unrelated files - Never read .env or commit secrets
First task (5 minutes)
Explain this open file in simple words, then suggest one small improvement with a unit test. Do not edit unrelated files. Wait for my approval before running shell commands.
- Open one source file and (optionally) select a function.
- Paste the prompt in the Codex sidebar.
- Read the summary and the diff. Keep only what you understand.
- If it offers cloud delegation, use it only when your plan includes Codex Cloud and the task is large.
- Commit to Git first so you can undo.
| Client | Best for |
|---|---|
| Codex VS Code extension | Day-to-day chat, edits, diffs beside code |
| Codex CLI | Terminal workflows, scripts, CI-style codex exec |
| ChatGPT macOS app + VS Code | Quick questions/edits from the desktop app (Mac) |
- Never paste API keys or .env into Codex chat.
- Company ChatGPT workspace admins may disable Codex — ask IT first.
Quick quiz
1. What is the VS Code extension ID?
openai.chatgpt (title: Codex – OpenAI’s coding agent).
2. How do you sign in?
With your ChatGPT account in the extension or CLI.
3. Where is shared config often stored?
~/.codex/config.toml.
4. Is Codex Cloud the same on every ChatGPT plan?
No — cloud tasks are plan-dependent; re-check OpenAI Help Center.
Save tokens and money
Reference the open file/selection instead of pasting megabytes. One task per chat. Use cloud only for long jobs your plan includes.