codecamp

在 OpenClaw 中通过 API 密钥或 Codex 订阅使用 OpenAI

OpenAI 提供 GPT 模型的开发者 API。Codex 支持ChatGPT 登录进行订阅访问,或API 密钥登录进行按量计费访问。Codex 云端需要 ChatGPT 登录。

方式 A:OpenAI API 密钥(OpenAI Platform)

适用于:直接 API 访问和按量计费。 从 OpenAI 控制台获取你的 API 密钥。

CLI 设置

openclaw onboard --auth-choice openai-api-key
## 或非交互式
openclaw onboard --openai-api-key "$OPENAI_API_KEY"

配置片段

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

方式 B:OpenAI Code(Codex)订阅

适用于:使用 ChatGPT/Codex 订阅访问而非 API 密钥。 Codex 云端需要 ChatGPT 登录,而 Codex CLI 支持 ChatGPT 或 API 密钥登录。

CLI 设置

## 在向导中运行 Codex OAuth
openclaw onboard --auth-choice openai-codex


## 或直接运行 OAuth
openclaw models auth login --provider openai-codex

配置片段

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

注意事项

OpenClaw Ollama 提供商配置指南
在 OpenClaw 中使用 OpenCode Zen(精选模型)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

OpenClaw 消息渠道

OpenClaw 工具

OpenClaw 模型

OpenClaw 平台

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }