惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
N
News | PayPal Newsroom
雷峰网
雷峰网
Y
Y Combinator Blog
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
Blog — PlanetScale
Blog — PlanetScale
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
The Cloudflare Blog
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
Vercel News
Vercel News
N
Netflix TechBlog - Medium
GbyAI
GbyAI
博客园 - 司徒正美
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
P
Proofpoint News Feed
I
InfoQ
IT之家
IT之家
F
Full Disclosure
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
Forbes - Security
Forbes - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
The Last Watchdog
The Last Watchdog
月光博客
月光博客
W
WeLiveSecurity
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
T
Threat Research - Cisco Blogs
D
DataBreaches.Net
P
Privacy & Cybersecurity Law Blog
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - Franky
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org

好好学习的郝

ClawdBot(OpenClaw)试用记录 编程辅助工具 Claude Code 入门篇 Claude API 中转服务 Claude Relay Service LLM 接口管理和分发系统 New API 好好学Git:Git Submodule详解 编程辅助工具Cursor入门篇 好好学Golang:Golang问题记录 One API配置自定义渠道 FastAPI入门篇 好好学Docker:使用Docker安装配置AList 好好学Docker:容器指标查看工具ctop 好好学Docker:自建RustDesk Server 好好学Linux:Ubuntu18 升级到 Ubuntu22 好好学Docker:使用Docker安装配置FileBrowser 邮箱配置中的SPF、DKIM、DMARC记录 One API 开发环境配置 LLM 接口管理和分发系统 One API 好好学K8S:K8S中的Leader Election机制 好好学Golang:Viper库
编程辅助工具 Codex 入门篇
本文作者: 好好学习的郝 · 2025-10-01 · via 好好学习的郝

Codex 是一个辅助编程的命令行工具,借助GPT系列模型提高编码的速度和质量。
Codex的安装配置方法和Claude Code很像(几乎一模一样),本文会对Codex的基础配置和用法进行说明,方便大家入手使用。

相关文档:

2. 安装Codex

2.1. 安装node.js 18+

  1. 安装nvm

    1
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
  2. 安装node.js 20

    1
    2
    3
    nvm install v20.19.4
    nvm use v20.19.4
    nvm alias default v20.19.4

2.2. 安装Codex

1
npm install -g @openai/codex

2.3. 初始化Codex

1
codex

出现提示:

1
2
3
4
5
6
7
8
9
10
11
12
  Welcome to Codex, OpenAI's command-line coding agent

Sign in with ChatGPT to use Codex as part of your paid plan
or connect an API key for usage-based billing

> 1. Sign in with ChatGPT
Usage included with Plus, Pro, and Team plans

2. Provide your own API key
Pay for what you use

Press Enter to continue

这里不用再继续配置,直接 ctrl+C 退出。

3. 安装配置OpenAI API代理

Codex依赖OpenAI API,但是因为国内无法访问OpenAI,所以我们需要一些访问OpenAI API的替代方案。
推荐使用NewAPI,它是OneAPI停止更新后的更强继承者。

4. 配置Codex

  1. 创建codex配置文件
    1
    vim ~/.codex/config.toml

假设使用的Claude API代理是NewAPI,那么填入如下内容:

1
2
3
4
5
6
7
8
9
model = "gpt-5"
model_provider = "new-api"
model_reasoning_effort = "medium"

[model_providers.new-api]
name = "New Api OpenAI"
base_url = "https://newapi.voidking.com/v1"
env_key = "NEW_OPENAI_API_KEY"
wire_api = "chat"

特别注意的是不能将 api_key 作为字符串直接传递给 env_key。 env_key 必须指向环境变量。

  1. 配置key环境变量
    1
    2
    3
    4
    echo 'export NEW_OPENAI_API_KEY="xxx"' >> ~/.zshrc
    source ~/.zshrc


5. 命令行使用Codex

1
2
cd your-project
codex

6. VSCode/Cursor使用Codex

  1. 安装插件 Codex – OpenAI’s coding agent
    插件安装完成,VSCode右上角会出现OpenAI图标

  2. 点击VSCode右上角会OpenAI图标,启动Codex
    首次启动会比较慢(半分钟左右),请耐心等待。

  3. 输入需求,辅助编程

7. Codex基础用法

参考文档: