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

# Codex CLI 配置指南

> Codex 集成指南 - Ace Data Cloud

## 1. 获取 API Key

打开 [Ace Data Cloud 应用列表](https://platform.acedata.cloud/console/applications)，进入可用的应用并复制 API Key。

![获取 Ace Data Cloud API Key](https://cdn.acedata.cloud/dvc3cg.jpg)

## 2. 安装 Codex

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

## 3. 设置 API Key

macOS / Linux：

```bash theme={null}
export ACEDATACLOUD_API_KEY="你的 API Key"
```

如需长期生效，把这一行加入 `~/.zshrc` 或 `~/.bashrc`。Windows PowerShell 使用：

```powershell theme={null}
setx ACEDATACLOUD_API_KEY "你的 API Key"
```

设置后重新打开终端。

## 4. 配置 AceDataCloud

编辑 `~/.codex/config.toml`（Windows 为 `%USERPROFILE%\.codex\config.toml`），加入：

```toml theme={null}
model_provider = "acedatacloud"

[model_providers.acedatacloud]
name = "acedatacloud"
base_url = "https://api.acedata.cloud/v1"

[model_providers.acedatacloud.auth]
command = "sh"
args = ["-c", "echo $ACEDATACLOUD_API_KEY"]
```

Windows 将最后两行改为：

```toml theme={null}
command = "powershell"
args = ["-NoProfile", "-Command", "Write-Output $env:ACEDATACLOUD_API_KEY"]
```

无需填写 `model`；启动后可在 Codex 中选择模型。已有其他配置可以保留，不要重复创建同名 provider。

## 5. 启动

```bash theme={null}
cd /path/to/your/project
codex
```

进入 Codex 后运行 `/model`，确认 Provider 为 `acedatacloud`，再选择需要的模型。调用记录和余额可在 [使用历史](https://platform.acedata.cloud/console/usages) 与 [应用列表](https://platform.acedata.cloud/console/applications) 查看。

如果提示缺少 Key 或返回 401，确认环境变量已设置，并完全退出后重新打开终端和 Codex。
