> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiji.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex 安装与配置

> 安装 Codex，并配置为使用吉吉API。

## 安装

<Tabs>
  <Tab title="macOS">
    **方法一：官方安装脚本（推荐）**

    ```bash theme={null}
    curl -fsSL https://chatgpt.com/codex/install.sh | sh
    ```

    **方法二：Homebrew**

    ```bash theme={null}
    brew install --cask codex
    ```

    **方法三：npm（国内镜像）**

    ```bash theme={null}
    npm i -g @openai/codex --registry=https://registry.npmmirror.com
    ```
  </Tab>

  <Tab title="Windows">
    **方法一：官方安装脚本（推荐）**

    在 PowerShell 中运行：

    ```powershell theme={null}
    powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
    ```

    **方法二：npm（国内镜像）**

    ```powershell theme={null}
    npm i -g @openai/codex --registry=https://registry.npmmirror.com
    ```

    <Tip>
      习惯在 WSL 中开发，也可以在 WSL 终端里按 Linux 方式安装，此时配置文件位于 WSL 内的 `~/.codex/`。
    </Tip>
  </Tab>

  <Tab title="Linux">
    **方法一：官方安装脚本（推荐）**

    ```bash theme={null}
    curl -fsSL https://chatgpt.com/codex/install.sh | sh
    ```

    **方法二：npm（国内镜像）**

    ```bash theme={null}
    npm i -g @openai/codex --registry=https://registry.npmmirror.com
    ```
  </Tab>
</Tabs>

<Note>
  官方安装脚本从 `chatgpt.com` 下载。网络无法访问时改用 npm 国内镜像，npm 方式需要先准备 [Node.js 环境](/environment/setup)。
</Note>

安装完成后，**打开一个新的终端窗口**，确认安装成功：

```bash theme={null}
codex --version
```

## 创建 API Key

在 [API 密钥](https://www.jiji.cc/keys) 页面新建一个 Key，分组选择包含 Codex 模型的分组，例如 VIP 企业组。各分组区别见 [套餐价格](https://www.jiji.cc/#pricing)。

## 配置

配置文件位于：

* **macOS/Linux**：`~/.codex/`
* **Windows**：`C:\Users\你的用户名\.codex\`

需要两个文件，目录或文件不存在时新建。

<Steps>
  <Step title="创建 config.toml">
    ```toml config.toml theme={null}
    model_provider = "jiji"
    model = "gpt-6.1-sol"
    model_reasoning_effort = "xhigh"
    disable_response_storage = true

    [model_providers.jiji]
    name = "吉吉API"
    base_url = "https://www.jiji.cc/v1"
    wire_api = "responses"
    requires_openai_auth = true
    ```

    <Info>
      **Windows 用户**可以在文件开头额外加一行 `windows_wsl_setup_acknowledged = true`，跳过首次启动时的 Windows 引导提示。
    </Info>
  </Step>

  <Step title="创建 auth.json">
    ```json auth.json theme={null}
    {
      "OPENAI_API_KEY": "your-api-key-here"
    }
    ```

    <Warning>
      将 `your-api-key-here` 替换为你的 API Key。
    </Warning>
  </Step>
</Steps>

| 配置项 | 说明 |
| - | - |
| `model_provider` | 使用的服务商，必须和下方 `[model_providers.jiji]` 中的名称一致 |
| `model` | 默认模型，可用模型以 [模型广场](https://www.jiji.cc/extension/models) 为准 |
| `model_reasoning_effort` | 思考强度，任务越复杂可以设得越高 |
| `base_url` | 吉吉API 请求地址，**必须**以 `/v1` 结尾 |
| `wire_api` | 接口格式，固定为 `responses` |
| `requires_openai_auth` | 从 `auth.json` 读取 API Key |

## 验证

在终端运行 `codex`，看到对话界面并能正常回复即配置完成：

```bash theme={null}
codex
```

<Tip>
  ChatGPT 桌面应用的 Codex 模式、Codex 的 VS Code 扩展与命令行共用 `~/.codex/` 下的这份配置，配置一次即可通用。
</Tip>

## 遇到问题

<Card title="Codex 常见问题" icon="circle-question" href="/codex/faq">
  安装、配置与错误排查
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.