Skip to content

OpenAI

OpenAI 为 GPT 模型提供开发者 API。Codex 支持 ChatGPT 登录以获取订阅访问权限,或支持 API 密钥登录以获取按使用量计费的访问权限。Codex cloud 需要 ChatGPT 登录。

选项 A:OpenAI API 密钥(OpenAI 平台)

**最适合:**直接 API 访问和按使用量计费。 从 OpenAI 控制台获取您的 API 密钥。

CLI 设置

bash
openclaw onboard --auth-choice openai-api-key
# or non-interactive
openclaw onboard --openai-api-key "$OPENAI_API_KEY"

配置片段

json5
{
  env: { OPENAI_API_KEY: "sk-..." },
  agents: { defaults: { model: { primary: "openai/gpt-5.2" } } },
}

选项 B:OpenAI Code(Codex)订阅

**最适合:**使用 ChatGPT/Codex 订阅访问而不是 API 密钥。 Codex cloud 需要 ChatGPT 登录,而 Codex CLI 支持 ChatGPT 或 API 密钥登录。

CLI 设置

bash
# Run Codex OAuth in the wizard
openclaw onboard --auth-choice openai-codex

# Or run OAuth directly
openclaw models auth login --provider openai-codex

配置片段

json5
{
  agents: { defaults: { model: { primary: "openai-codex/gpt-5.2" } } },
}

注意事项