Codex CLI轻量级 AI 编程智能体 :openai又放大招了

Codex CLI是轻量级 AI 编程智能体,基于自然语言指令帮助开发者高效生成代码、执行文件操作和进行版本控制。

源码:https://github.com/openai/codex

安装

只要有npm就可以安装:

# npm install codex
sudo npm install -g @openai/codex

设置环境变量OPENAI_API_KEY

Next, set your OpenAI API key as an environment variable:

export OPENAI_API_KEY="your-api-key-here"

Note: This command sets the key only for your current terminal session. You can add the export line to your shell's configuration file (e.g., ~/.zshrc) but we recommend setting for the session. Tip: You can also place your API key into a .env file at the root of your project:

OPENAI_API_KEY=your-api-key-here

The CLI will automatically load variables from .env (via dotenv/config).

然后直接运行codex即可:

Run interactively:

codex

Or, run with a prompt as input (and optionally in Full Auto mode):

或者是直接跟上prompt:

codex "explain this codebase to me"
codex --approval-mode full-auto "create the fanciest todo-list app"

skywalk@fb:~ $ OPENAI_API_KEY=hello
skywalk@fb:~ $ OPENAI_URL_BASE=http://192.168.1.5:1337/v1 

OPENAI_URL_BASE=http://192.168.1.5:1337/v1 OPENAI_API_KEY=hello codex
╭──────────────────────────────────────────────────────────────╮
│ ● OpenAI Codex (research preview) v0.1.2504251709            │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│Warning! It can be dangerous to run a coding agent outside of a git repo in case there are changes that you want to   │
│revert. Do you want to continue?                                                                                      │
│                                                                                                                      │
│/home/skywalk                                                                                                         │
│                                                                                                                      │
│y/N                                                                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

配置

vi ~/.codex/config.json

写配置:

{
  "model": "o4-mini",
  "provider": "openai",
  "providers": {
    "openai": {
      "name": "OpenAI",
      "baseURL": "http://192.168.1.5:1337/v1",
      "envKey": "OPENAI_API_KEY"
    },
}
}

启动

OPENAI_API_KEY=hello codex

总结:

codex并没有调试通,后来是安装了codex的国内个人升级版:codexy,倒是调试成功了,具体见:codexy一个在终端中运行的轻量级编码助手(OpenAI Codex CLI Python 版本)-CSDN博客

总之,因为openai本身的问题,导致codex的调试极难,最终放弃,还是改投codexy

调试

一直打印横向字符串

一直没调试好....

咨询:Which models are supported?

Any model available with Responses API. The default is o4-mini, but pass --model gpt-4.1 or set model: gpt-4.1 in your config file to override.

Sorry, you have been blocked

You are unable to access openai.com

大约就是用openai的大部分模型都可以。 

修改了model gpt-4o,但是没改过来

 model: o4-mini                                             │
│ ↳ provider: openai                                           │
│ ↳ approval: suggest

后来在命令行里带了模型,终于改过来了。codex "explain this codebase to me" --model deepseek-v3

还是报超时,就好像.codex/config.json文件没有起作用一样

 里面的baseurl没起作用,在命令行里带上:

codex "explain this codebase to me" --model deepseek-v3 --baseURL "http://192.168.1.5:1337/v1"

还是报错超时:

system
    ⚠️  Network error while contacting OpenAI. Please check your connection and try again.

所以一直没有调通 

在WSL Ubuntu22环境下报错SyntaxError: Unexpected token '?'

codex
SyntaxError: Unexpected token '?'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
    at async link (internal/modules/esm/module_job.js:42:21)

AI说:升级 Node.js‌ 是最直接的解决方案。

不明白啥原因

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值