How to Use OpenClaw with GPT-4 (OpenAI) — Setup Guide
Configure OpenClaw to use OpenAI GPT-4 and GPT-4o as your LLM backend. Covers API key setup, model selection, and cost optimization tips.
OpenAI's GPT-4 is one of the most popular LLM choices for OpenClaw. The setup is straightforward, and GPT-4o (the omni model) offers a solid balance of capability and cost for running an always-on agent.
Get Your OpenAI API Key
Log into platform.openai.com, go to API Keys, and create a new secret key. Make sure you've added a payment method — the API doesn't work on a free tier for GPT-4.
Configure OpenClaw
openclaw config set llm.provider openai
openclaw config set llm.apiKey sk-YOUR_OPENAI_KEY
openclaw config set llm.model gpt-4oThen restart the gateway:
openclaw gateway restart
openclaw gateway status
# Should show: LLM: openai/gpt-4o ✓Available OpenAI Models
- gpt-4o — Best all-around choice. Fast, multimodal, well-priced
- gpt-4o-mini — Much cheaper, great for high-frequency cron tasks
- gpt-4-turbo — Older but very capable, 128K context
- o1-mini — Reasoning model for complex multi-step problems
openclaw.json Configuration
{
"llm": {
"provider": "openai",
"model": "gpt-4o",
"apiKey": "sk-YOUR_KEY_HERE",
"temperature": 0.7,
"maxTokens": 4096
}
}Cost Optimization: Use Mini for Crons
GPT-4o is great for your main agent interactions. For cron jobs that run frequently (hourly, every 5 min), use the mini model to save money:
openclaw cron update hex-monitor-check \
--model "openai/gpt-4o-mini"
openclaw cron update hex-daily-brief \
--model "openai/gpt-4o"Testing Your Setup
openclaw chat --message "tell me which model you're running on"
# Should respond mentioning GPT-4o
openclaw gateway logs --tail 20 | grep openaiUsing OpenAI with OpenRouter
Alternatively, you can access GPT-4 through OpenRouter, which gives you a single API key and automatic fallback routing. See the OpenRouter integration guide.
Want the full OpenClaw setup guide? The OpenClaw Playbook covers everything — $9.99.
Frequently Asked Questions
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.