CodeToInfinity
Codex CLI SetupCodex CLI 安装教程

Install Codex and connect your gateway.安装 Codex,并接入你的网关。

A short setup guide for using OpenAI Codex CLI with CodeToInfinity. Install Codex, create your key, set the gateway URL, and start running terminal agent workflows.这是一份面向 CodeToInfinity 的 Codex CLI 快速接入教程:安装 Codex、生成 Key、配置网关地址,然后开始使用终端 Agent 工作流。

1. Requirements1. 准备工作

Node.jsNode.jsUse a current LTS version so npm can install the Codex package cleanly.建议使用当前 LTS 版本,确保 npm 可以正常安装 Codex 包。
CodeToInfinity keyCodeToInfinity KeyCreate a key in the console before configuring Codex.先在控制台生成一个可用 Key,再配置 Codex。

2. Install Codex CLI2. 安装 Codex CLI

The common installation path is npm. If you prefer not to use npm, check the official GitHub releases for platform binaries.常用安装方式是 npm。如果你不想用 npm,也可以到官方 GitHub Releases 下载对应平台的二进制文件。

$ npm install -g @openai/codex
$ codex --version
Official reference: openai/codex on GitHub.官方参考:openai/codex GitHub 仓库

3. Connect CodeToInfinity3. 接入 CodeToInfinity

Point Codex to the CodeToInfinity API endpoint and use the key you created in the console.把 Codex 指向 CodeToInfinity API 入口,并使用你在控制台生成的 Key。

$ export OPENAI_BASE_URL=https://api.codetoinfi.com/v1
$ export OPENAI_API_KEY=cti_xxx_replace_with_your_key
$ codex

For a permanent setup, add these exports to your shell profile, such as ~/.zshrc or ~/.bashrc.如果想长期生效,可以把这两行加入 ~/.zshrc~/.bashrc

4. Verify the workflow4. 验证工作流

  1. Run codex in a project directory.在一个项目目录里运行 codex
  2. Ask a small coding question or file-reading task first.先让它执行一个小的代码问题或文件阅读任务。
  3. Open the CodeToInfinity console and check quota, usage, and request details.回到 CodeToInfinity 控制台查看额度、用量和请求明细。

Troubleshooting常见问题

Command not found找不到 codex 命令

Restart your terminal, then check whether your global npm bin directory is in PATH.重启终端,并检查 npm 全局安装目录是否在 PATH 中。

401 or invalid key401 或 Key 无效

Confirm the key is active in the console and that OPENAI_API_KEY has no extra spaces.确认控制台里的 Key 是启用状态,并检查 OPENAI_API_KEY 没有多余空格。

Slow or failed model call模型调用慢或失败

Check your usage details in the console. If quota is available but calls fail, contact support with the request time and model name.先在控制台查看调用明细。如果额度正常但请求失败,请带上请求时间和模型名称反馈。