How to Set Up OpenAI OAuth & Select Models in OpenClaw
Rajen Sikder
Setting up OpenAI authentication via OAuth in OpenClaw and routing your active models through it takes just a couple of minutes. Here is a step-by-step guide formatted like a quick developer blog post.
How to Set Up OpenAI OAuth & Select Models in OpenClaw
When running OpenClaw, you can authenticate OpenAI using standard API keys or via OAuth / Subscription Auth. Using OAuth allows OpenClaw to leverage your ChatGPT subscription and manage OAuth profile tokens directly inside OpenClaw's local profile store.
Follow this guide to authenticate, discover available models, and switch your active primary model.
Step 1: Authenticate via OAuth
Run the auth login command for OpenAI:
Bash
openclaw models auth login --provider openaiWhat happens next:
OpenClaw will output an authentication link or trigger a PKCE browser flow.
Log into your OpenAI account and approve OpenClaw's access.
Once completed, OpenClaw stores the refresh token into its internal SQLite database for your agent.
Tip (Multiple Accounts): If you manage multiple OpenAI profiles (e.g., personal vs. work), save them with specific profile IDs:
Bash
openclaw models auth login --provider openai --profile-id openai:work
Step 2: List and Probe Available Models
Now that your credentials are set up, verify what models your OAuth account can access.
Option A: List models registered in your local catalog
Bash
openclaw models list --provider openaiOption B: Perform a live probe against the OpenAI API
To verify active credentials and ping the provider for your current token limits and live model access, run:
Bash
openclaw models status --probeStep 3: Set Your Active Model
Select the OpenAI model you want OpenClaw to use as its primary engine.
Bash
openclaw models set openai/gpt-4o(Replace openai/gpt-4o with any model ID returned from your openclaw models list step, such as openai/gpt-4o-mini or openai/gpt-5.6-sol if available on your account).
Verify the change:
Bash
openclaw models statusYou should now see openai/<your-model> marked as the active primary model for your gateway.
Quick Reference Summary
Bash
# 1. Start OAuth login flow
openclaw models auth login --provider openai
# 2. Check accessible models
openclaw models list --provider openai
# 3. Set primary active model
openclaw models set openai/gpt-4o
# 4. Confirm active model status
openclaw models statusClaim 80% Off Your OpenClaw Setup
Get instant access to managed OpenClaw hosting and agent automation. Enjoy 80% off on all OpenClaw managed hosting plans—use coupon code OC80 at checkout to save on your first month.
Claim 80% Discount