OpenAI
Use OpenAI in OpenClaw: supports API keys or Codex subscription auth.
OpenAI provides developer APIs for GPT series models. Codex supports using <strong>ChatGPT login</strong> (subscription access) or <strong>API Key login</strong> (pay-as-you-go access). Codex cloud requires ChatGPT login.
Option A: OpenAI API Key (OpenAI Platform)
<strong>Best for:</strong> Direct API access and pay-as-you-go billing.
Get your API Key from the OpenAI console.
#
CLI Setup
openclaw onboard --auth-choice openai-api-key openclaw onboard --openai-api-key "$OPENAI_API_KEY"
#
Config Snippet
{
env: { OPENAI_API_KEY: "sk-..." },
agents: { defaults: { model: { primary: "openai/gpt-5.2" } } },
}Option B: OpenAI Code (Codex) Subscription
<strong>Best for:</strong> Using ChatGPT/Codex subscription access instead of API Key.
Codex cloud requires ChatGPT login, while Codex CLI supports ChatGPT login or API Key login.
#
CLI Setup
openclaw onboard --auth-choice openai-codex openclaw models auth login --provider openai-codex
#
Config Snippet
{
agents: { defaults: { model: { primary: "openai-codex/gpt-5.2" } } },
}Notes
- Model refs use '<code className="bg-white/10 px-1.5 py-0.5 rounded text-emerald-300 text-sm">'provider/model'</code>' (see '<a href="/concepts/models" className="text-emerald-400 hover:text-emerald-300 transition-colors">'/concepts/models'</a>').
- See '<a href="/concepts/oauth" className="text-emerald-400 hover:text-emerald-300 transition-colors">'/concepts/oauth'</a>' for auth details and reuse rules.