English
  • English
  • 中文简体
English
  • English
  • 中文简体
English
  • English
  • 中文简体
  1. Tool Configuration Tutorial
  • Model interface
    • Aiide Platform
    • Law and Policy
      • Service Agreement
      • Privacy Policy
    • List of model interfaces
      • Get Models
        • Get Available Models
      • Anthropic (Claude Code)
        • Official API
          • Text Chat (Preferred)
        • OpenAI-Compatible API
          • Text Chat
      • OpenAI (Codex, GPT-Image-2)
        • Official API
          • Text Chat (Officially Recommended / Next Generation)
          • Text Chat (Compatible API)
          • Generate Image (GPT-Image-2)
          • Edit Image (GPT-Image-2)
          • Create Video
          • Get Video Task Status
          • Get Video Content
      • Google (Gemini, Nano Banana)
        • Official API
          • Text Chat (Preferred)
          • Generate Image (Nano Banana)
        • OpenAI-Compatible API
          • Text Chat
          • Generate Image (Nano Banana)
      • xAI (Grok-Image)
        • OpenAI-Compatible API
          • Generate Image (Grok)
      • Images
        • OpenAI-Compatible API
          • Generate Image
        • Qwen-Compatible Format
          • Generate Image
          • Edit Image
      • Videos
        • Qwen Format (Happyhorse)
          • Create Video (Text-to-Video)
          • Create Video (First-Frame Image-to-Video)
          • Create Video (Reference-Image-to-Video)
          • Create Video (Video Editing)
          • Get Video Generation Task Status
        • Volcengine Doubao Format (Seed-2.0)
          • Create Video (Multimodal Reference-to-Video)
          • Get Video Generation Task Status
        • OpenAI Format (Google Veo 3.1, Seed-2.0)
          • Google Veo 3.1
            • Create Video (Text-to-Video)
            • Create Video (Reference-Image-to-Video)
            • Get Video Generation Task Status
          • OpenAI Sora Format (Seed-2.0 Special Price)
            • Create Video (Text-to-Video)
            • Create Video (Multimodal Reference-to-Video)
            • Get Video Generation Task Status
            • Get Video Content
    • Video Asset APIs
      • Asset Library API Integration Guide
      • Asset Library API Integration Guide (Volcengine Official Format)
      • Upload Asset
      • List Assets
      • Get Asset
      • Update Asset Description
      • Delete Asset
    • Tool Configuration Tutorial
      • CC Switch 配置
      • Claude Code配置
      • Codex配置
      • Gemini CLI配置
      • OpenCode 配置
      • Cursor 配置
      • node 安装教程
  1. Tool Configuration Tutorial

Codex配置

OpenAI Codex CLI 配置教程#

获取 API Key 后,按照你的操作系统选择对应步骤完成配置。

步骤 1:验证是否安装 Node.js#

Codex Cli 基于 Node.js 运行,请先确认已安装 Node.js(建议 LTS 版本)。
打开终端
windows用户(win+R)输入 cmd 回车
分别执行
node -v
npm -v
查看是否有版本号,如果没有显示版本号的可以参考 node 安装教程 进行安装
image.png

步骤 2:安装 Codex CLI#

Windows(PowerShell,无需 sudo)#

npm install -g @openai/codex

macOS / Linux / WSL2#

如果使用 nvm 管理 Node.js,可以不加 sudo。
验证安装:

步骤 3:创建配置文件#

如果使用CC Switch的可以跳转 CC Switch 配置
Codex CLI 通过配置文件指定模型提供商和认证方式。

配置文件路径#

系统路径
Windows%USERPROFILE%\.codex\config.toml
macOS / Linux~/.codex/config.toml

创建目录#

Windows#

New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex"

macOS / Linux / WSL2#

写入配置文件#

将下方内容写入 config.toml:
model_provider = "aiide"
model = "gpt-5-codex"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"

[model_providers.aiide]
name        = "aiide"
base_url    = "https://www.aiide.com/v1"
wire_api    = "responses"
env_key     = "OPENAI_API_KEY"

步骤 4:配置 API Key#

将 API Key 设置为环境变量,供 Codex CLI 读取。

Windows(PowerShell)#

临时生效(仅当前终端会话有效):
$env:OPENAI_API_KEY = "YOUR_API_KEY"
永久生效(推荐):
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "YOUR_API_KEY", "User")
设置后需重新打开终端窗口。

macOS / Linux / WSL2#

将以下内容追加到 ~/.bashrc 或 ~/.zshrc:
然后使配置立即生效:

步骤 5:验证配置#


常见问题#

Q:环境变量设置后不生效?
重新打开一个终端窗口,或执行 source ~/.bashrc。
Q:Windows 安装时提示权限错误?
以管理员身份运行 PowerShell 后重试。
Q:启动后提示找不到模型提供商?
检查 config.toml 中 base_url 是否填写正确,路径末尾不要带多余的斜杠。
Modified at 2026-05-29 06:06:16
Previous
Claude Code配置
Next
Gemini CLI配置
Built with