> ## 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 for VS Code 配置指南

> Codex 集成指南 - Ace Data Cloud

Codex VS Code 扩展与 Codex CLI 共用 `~/.codex/config.toml`。

## 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. 安装扩展

在 VS Code 扩展市场安装 OpenAI 发布的 **Codex – OpenAI's coding agent**，或运行：

```bash theme={null}
code --install-extension openai.chatgpt
```

## 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 面板中选择模型。

## 5. 重启并验证

完全退出并重新打开 VS Code，再打开 Codex 面板。运行 `/model`，确认 Provider 为 `acedatacloud`，然后发送一条简单消息；调用记录可在 [使用历史](https://platform.acedata.cloud/console/usages) 查看。

如果扩展读不到 Key，请从已设置环境变量的终端启动 VS Code，或设置系统级环境变量后重启 VS Code。Remote SSH、WSL 和 Dev Container 需要在实际运行扩展的环境中分别配置。
