← Home

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

  1. Go to platform.openai.com/api-keys.
  2. Sign in or create an OpenAI account.
  3. Click Create new secret key. Give it a name (e.g., "OpenClaw").
  4. Copy the key — it starts with sk-...
  5. Ensure you have billing set up under Settings → Billing. API usage is pay-as-you-go.
Tip: Set a monthly spending limit in your OpenAI dashboard to avoid unexpected charges. You can find this under Settings → Limits.

Step 2: Configure in OpenClaw

Option A: OpenClaw Launch (Easiest)

  1. Go to openclawlaunch.com and open the configurator.
  2. Select OpenAI as your AI model provider and paste your API key.
  3. Choose a model (e.g., GPT-5.2, o3-mini, GPT-4.1).
  4. 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

ModelBest ForSpeed
GPT-5.2Most capable, complex tasksMedium
o3Reasoning, math, codingSlow (thinks longer)
o3-miniFast reasoning, budget-friendlyFast
GPT-4.1Good balance, previous genFast
GPT-4.1-miniBudget daily chatVery 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.

Deploy a GPT-Powered Bot

Get an OpenAI-powered AI agent on Telegram or Discord in 30 seconds.

Configure & Deploy