Guide
How to Use OpenAI GPT with OpenClaw
Power your OpenClaw AI agent with OpenAI's models — GPT-5.2, o3, Codex, and more. Get your API key, configure the model, and deploy in 30 seconds.
Why Use OpenAI with OpenClaw?
OpenAI's GPT models are among the most widely used AI models. Combined with OpenClaw's 5,700+ skills, you get a powerful agent that can browse the web, write code, manage files, generate images, and more — all accessible via Telegram, Discord, or the web gateway.
Step 1: Get an OpenAI API Key
- Go to platform.openai.com/api-keys.
- Sign in or create an OpenAI account.
- Click Create new secret key. Give it a name (e.g., "OpenClaw").
- Copy the key — it starts with
sk-... - Ensure you have billing set up under Settings → Billing. API usage is pay-as-you-go.
Step 2: Configure in OpenClaw
Option A: OpenClaw Launch (Easiest)
- Go to openclawlaunch.com and open the configurator.
- Select OpenAI as your AI model provider and paste your API key.
- Choose a model (e.g., GPT-5.2, o3-mini, GPT-4.1).
- Select your chat platform, paste the bot token, and click Deploy.
Option B: Self-Hosted Config
If self-hosting, add the OpenAI provider to openclaw.json:
{
"models": {
"providers": {
"openai": {
"apiKey": "sk-..."
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "openai/gpt-5.2"
}
}
}
}Step 3: Choose a Model
| Model | Best For | Speed |
|---|---|---|
| GPT-5.2 | Most capable, complex tasks | Medium |
| o3 | Reasoning, math, coding | Slow (thinks longer) |
| o3-mini | Fast reasoning, budget-friendly | Fast |
| GPT-4.1 | Good balance, previous gen | Fast |
| GPT-4.1-mini | Budget daily chat | Very fast |
For most users, GPT-5.2 is the best all-around choice. Use o3-mini if you need strong reasoning at a lower cost. Use GPT-4.1-mini for budget-conscious daily chatting.
Using Codex with OpenClaw
OpenAI Codex is optimized for code generation and completion. To use Codex models with OpenClaw, configure the model in your agent settings. Codex excels at:
- Writing and refactoring code across many languages
- Explaining code snippets and debugging
- Generating scripts and automation
- Converting natural language to code
OpenAI via OpenRouter
Instead of using OpenAI directly, you can route through OpenRouter for unified billing across multiple AI providers. OpenClaw Launch uses OpenRouter by default when you select the included AI credits option.
Switching Models
You can switch between OpenAI models (or to a different provider entirely) at any time using the /model chat command — no redeployment needed. OpenClaw supports Claude, Gemini, DeepSeek, and more alongside OpenAI.
See our Models page for a full comparison of all supported AI models.