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

# Codex CLI

> Codex 是 OpenAI 官方的命令行 AI 编程工具

## 前置条件

* 已 [创建 API 密钥](/create-token)
* 如果通过 NPM 安装，需要已安装 Node.js 22+

## 安装 Codex

<Tabs>
  <Tab title="macOS">
    官方一键安装（推荐）：

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

    或通过 Homebrew：

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

    或通过 NPM：

    ```bash theme={null}
    npm install -g @openai/codex
    ```
  </Tab>

  <Tab title="Windows">
    ```bash theme={null}
    npm install -g @openai/codex
    ```
  </Tab>
</Tabs>

## 配置

<Tabs>
  <Tab title="一站式导入（推荐）">
    通过 Teio 站点一键导入，无需手动复制 Key 和地址。需要先安装 [CC Switch](/cc-switch)。

    1. 打开 Teio **密钥**页面，点击密钥右侧下拉按钮，选择 **"CC 切换"**

    <Frame>
      <img src="https://mintcdn.com/cdhyzxwl/6LIm8QzGL-MXydIR/images/macshot-clipboard-CFC10349-AF02-4AF4-A24F-3E93D9BDB544.png?fit=max&auto=format&n=6LIm8QzGL-MXydIR&q=85&s=f2aea52777e880ace76720ce796309ed" alt="Macshot Clipboard CFC10349 AF02 4AF4 A24F 3E93D9BDB544" width="662" height="483" data-path="images/macshot-clipboard-CFC10349-AF02-4AF4-A24F-3E93D9BDB544.png" />
    </Frame>

    2. CC Switch 自动打开导入面板，补充供应商名称并选择模型
           <Frame>
             <img src="https://mintcdn.com/cdhyzxwl/6LIm8QzGL-MXydIR/images/macshot-clipboard-D049F5F7-E73D-4FB2-B331-9AC60DE78E46.png?fit=max&auto=format&n=6LIm8QzGL-MXydIR&q=85&s=ff3309b902a00bb6790377c740eed721" alt="Macshot Clipboard D049F5F7 E73D 4FB2 B331 9AC60DE78E46" width="1117" height="754" data-path="images/macshot-clipboard-D049F5F7-E73D-4FB2-B331-9AC60DE78E46.png" />
           </Frame>
    3. 点击"导入"完成
           <Frame>
             <img src="https://mintcdn.com/cdhyzxwl/6LIm8QzGL-MXydIR/images/macshot-clipboard-E4634FEA-AF0C-4CFC-B541-B90F73CF4B90.png?fit=max&auto=format&n=6LIm8QzGL-MXydIR&q=85&s=8f0122429514c4748065756f11308d5a" alt="Macshot Clipboard E4634FEA AF0C 4CFC B541 B90F73CF4B90" width="1159" height="1039" data-path="images/macshot-clipboard-E4634FEA-AF0C-4CFC-B541-B90F73CF4B90.png" />
           </Frame>
  </Tab>

  <Tab title="手动配置">
    创建 `~/.codex/config.toml` 和 `~/.codex/auth.json`（Windows 路径为 `C:\Users\<用户名>\.codex\`）。

    ```bash theme={null}
    mkdir -p ~/.codex
    ```

    `config.toml`：

    ```toml theme={null}
    model_provider = "teio"
    model = "gpt-5.5"
    model_reasoning_effort = "medium"
    disable_response_storage = true

    [model_providers.teio]
    name = "teio"
    base_url = "https://teio.me/v1"
    wire_api = "responses"
    requires_openai_auth = true
    web_search = "live"
    ```

    `auth.json`：

    ```json theme={null}
    {
      "OPENAI_API_KEY": "你的密钥"
    }
    ```
  </Tab>
</Tabs>

## 启动

<Note>
  如果你刚完成上述配置，请先重启终端，确保配置文件已被加载。
</Note>

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

如果配置正确，你会进入 Codex 的交互界面。

<Frame>
  <img src="https://mintcdn.com/cdhyzxwl/TGovpegLKDsR41EL/images/macshot-clipboard-B2155249-0BB3-4B7E-A7B4-C8C8EE754D2B.png?fit=max&auto=format&n=TGovpegLKDsR41EL&q=85&s=80c228e8782e7805f9a8e9d37b3dff43" alt="Macshot Clipboard B2155249 0BB3 4B7E A7B4 C8C8EE754D2B" width="1720" height="416" data-path="images/macshot-clipboard-B2155249-0BB3-4B7E-A7B4-C8C8EE754D2B.png" />
</Frame>

遇到问题？请参考 [常见问题](/faq)。
