📚AI 编程官方教程中文版
官方教程中文版产品入口

安装和使用 IDE 扩展

Codex IDE extension 让你在编辑器里直接使用 OpenAI 的 coding agent(编程 Agent)。它可以 read(读取)、edi

Codex IDE extension 让你在编辑器里直接使用 OpenAI 的 coding agent(编程 Agent)。它可以 read(读取)、edit(编辑)和 run code(运行代码),帮助你构建功能、修 bug、理解不熟悉的代码。

在 VS Code extension 里,你可以把 Codex 放在 IDE 侧边栏里和代码并排使用,也可以把任务 delegate(委托)给 Codex Cloud。

ChatGPT Plus、Pro、Business、Edu 和 Enterprise 计划都包含 Codex。计划包含内容见:

https://developers.openai.com/codex/pricing

官方概览视频:

https://www.youtube.com/watch?v=sd21Igx4HtA

Extension setup

Codex IDE extension 支持 VS Code forks(VS Code 分支编辑器),例如 Cursor 和 Windsurf。

你可以从 Visual Studio Code Marketplace 安装:

https://marketplace.visualstudio.com/items?itemName=openai.chatgpt

也可以按编辑器直接打开安装入口:

Codex IDE integrations 支持 macOS、Windows 和 Linux,覆盖 VS Code-compatible editors(兼容 VS Code 的编辑器)和 JetBrains IDEs。

在 Windows 上,你可以用 Windows sandbox 原生运行 Codex;如果需要 Linux-native environment(原生 Linux 环境),也可以使用 WSL2。Windows 设置见:

https://developers.openai.com/codex/windows

安装后,你会在 editor sidebar(编辑器侧边栏)看到 Codex。

在 VS Code 里,Codex 默认打开在右侧边栏。如果你安装后没有马上看到 Codex,重启 VS Code。

如果你使用 Cursor,activity bar(活动栏)默认是横向显示。折叠的项目可能会隐藏 Codex,所以可以 pin(固定)它,并重新调整 extensions 的顺序。

Codex extension 截图:

https://cdn.openai.com/devhub/docs/codex-extension.webp

JetBrains IDE integration

如果你想在 Rider、IntelliJ、PyCharm 或 WebStorm 等 JetBrains IDEs 里使用 Codex,安装 JetBrains IDE integration。

它支持三种登录方式:

  • ChatGPT 登录。
  • API key。
  • JetBrains AI subscription(JetBrains AI 订阅)。

安装入口:

https://blog.jetbrains.com/ai/2026/01/codex-in-jetbrains-ides/

Move Codex to the right sidebar

在 VS Code 中,Codex 会自动出现在 right sidebar(右侧边栏)。如果你更喜欢把它放在 primary sidebar(左侧主边栏),可以把 Codex icon 拖回左侧 activity bar。

在 Cursor 这类 VS Code forks 中,你可能需要手动把 Codex 移到右侧边栏。移动前,可能还需要临时修改 activity bar orientation(活动栏方向):

  1. 打开 editor settings,搜索 activity bar,位置在 Workbench settings。
  2. 把 orientation 改成 vertical
  3. 重启编辑器。

设置截图:

https://cdn.openai.com/devhub/docs/codex-workbench-setting.webp

然后把 Codex icon 拖到右侧边栏,例如放在 Cursor chat 旁边。Codex 会作为 sidebar 里的另一个 tab 出现。

移动完成后,可以把 activity bar orientation 重新设回 horizontal,恢复默认行为。

如果之后改变主意,随时可以把 Codex 拖回 primary sidebar。

Sign in

安装 extension 后,它会提示你使用 ChatGPT account 或 API key 登录。

ChatGPT plan 本身包含 usage credits,所以你不需要额外配置就能使用 Codex。价格和额度见:

https://developers.openai.com/codex/pricing

Update the extension

Extension 会自动更新。

你也可以在 IDE 里打开 extension page,手动检查是否有更新。

Set up keyboard shortcuts

Codex 提供可以绑定到 IDE keyboard shortcuts(快捷键)的 commands,例如:

  • toggle Codex chat(打开/关闭 Codex 聊天)。
  • add items to the Codex context(把项目加入 Codex 上下文)。

查看所有可用 commands 并绑定快捷键:

  1. 打开 Codex chat。
  2. 选择 settings icon(设置图标)。
  3. 选择 Keyboard shortcuts

命令列表见:

https://developers.openai.com/codex/ide/commands

Slash commands 列表见:

https://developers.openai.com/codex/ide/slash-commands

如果你刚开始使用 Codex,先读 best practices guide:

https://developers.openai.com/codex/learn/best-practices

Work with the Codex IDE extension

下面是 IDE extension 最常用的能力。

Prompt with editor context

使用 open files(已打开文件)、selections(选区)和 @file references(文件引用),用更短 prompt 得到更相关的结果:

https://developers.openai.com/codex/ide/features#prompting-codex

Switch models

使用 default model(默认模型),或切换到其他模型,发挥各自优势:

https://developers.openai.com/codex/ide/features#switch-between-models

Adjust reasoning effort

lowmediumhigh 之间选择 reasoning effort(推理强度),按任务在速度和深度之间取舍:

https://developers.openai.com/codex/ide/features#adjust-reasoning-effort

图片生成

无需离开编辑器,就可以生成或编辑图片;需要迭代时,也可以使用 reference assets(参考素材):

https://developers.openai.com/codex/ide/features#image-generation

Choose an approval mode

ChatAgentAgent (Full Access) 之间切换,根据你希望 Codex 拥有的 autonomy(自主程度)选择模式:

https://developers.openai.com/codex/ide/features#choose-an-approval-mode

Delegate to the cloud

把较长任务交给 cloud environment,在 IDE 里监控进度并 review 结果:

https://developers.openai.com/codex/ide/features#cloud-delegation

跟进云端任务

预览 cloud changes,继续要求 Codex follow up,然后把生成的 diffs 应用到本地测试和收尾:

https://developers.openai.com/codex/ide/features#cloud-task-follow-up

IDE extension commands

浏览可从 command palette(命令面板)运行、也可以绑定快捷键的完整 commands:

https://developers.openai.com/codex/ide/commands

斜杠命令

用 slash commands 控制 Codex 行为,并从聊天里快速修改常用设置:

https://developers.openai.com/codex/ide/slash-commands

Extension settings

通过 editor settings 调整模型、approvals 和其他默认行为:

https://developers.openai.com/codex/ide/settings

On this page