Integrate OpenAI Models in Openclaw

Image
Table of contents: [Show]

Connect GPT-5.4 and other OpenAI models to your Openclaw agent for powerful AI capabilities. This guide covers both standard API and Codex CLI integration methods.

OpenAI Models in Openclaw

Quick Start

Openclaw supports OpenAI models through two primary methods: the standard OpenAI API for general usage, and the OpenAI Codex CLI for coding-specific tasks. Both integrate seamlessly with your agent workflow.

Related Articles

Option 1: OpenAI API Key (Standard)

This is the recommended path for direct API access with usage-based billing.

Interactive Setup

Run the onboarding wizard and follow the prompts:

Openclaw onboard --auth-choice openai-api-key

Non-Interactive Setup

If you already have your key, configure it directly:

Openclaw onboard --openai-api-key "$OPENAI_API_KEY"

Configuration File

Alternatively, edit ~/.Openclaw/Openclaw.json directly:

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

Option 2: OpenAI Codex CLI

For coding-specific tasks, use the Codex CLI integration.

Configuration File

When using this method, model references must use the openai-codex/ prefix:

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

Testing Your Setup

Once configured, test your integration with a simple prompt:

{ "tool": "message", "content": "Hello from OpenAI via Openclaw!" }

Troubleshooting

  • Authentication errors: Verify your API key starts with sk- and has sufficient credits
  • Model not found: Ensure you're using the correct prefix (openai/ or openai-codex/)
  • Rate limiting: Check your OpenAI dashboard for usage limits and upgrade your tier if needed

With OpenAI models integrated, your Openclaw agent can now leverage GPT-5.4's advanced reasoning and code generation capabilities across all connected channels.