Anthropic OAuth Guide
Connect your Claude subscription to OpenClaw using setup-token auth.
Contents
📋 What You Need
✅ Prerequisites
- An active Claude Pro ($100/mo) or Max ($200/mo) subscription
- A computer to generate the token (laptop is fine)
- OpenClaw installed on your server
💡 Good to Know
- The token doesn't need to be generated on the same machine as OpenClaw
- You can generate it on your laptop and paste it into your server
- Flat-rate access to Opus, Sonnet, and Haiku
🔧 Step 1: Install Claude Code CLI
Claude Code CLI is the tool that generates the setup-token. Install it on any machine (your laptop, not necessarily your server).
macOS / Linux
# Install via npm (requires Node.js 18+)
npm install -g @anthropic-ai/claude-code
# Verify installation
claude --version
If you don't have Node.js
# macOS (Homebrew)
brew install node
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
# Then install Claude Code
npm install -g @anthropic-ai/claude-code
Windows
# Install Node.js from https://nodejs.org (LTS version)
# Then in PowerShell or CMD:
npm install -g @anthropic-ai/claude-code
First-time login
After installing, run Claude Code once to authenticate with your Anthropic account:
claude
# This opens a browser window to log in with your Anthropic account
# After login, Claude Code is authenticated and ready
🔑 Step 2: Generate the Setup-Token
On the machine where you installed Claude Code CLI:
claude setup-token
This outputs a token string. Copy it — you'll paste it into OpenClaw next.
🔌 Step 3: Connect to OpenClaw
On your OpenClaw server, paste the token. Choose one method:
Option A: During onboarding (first-time setup)
openclaw onboard
# When prompted for auth, choose one of:
# "Anthropic token (paste setup-token)" — paste the token from Step 2
# "Anthropic OAuth (Claude Code CLI)" — if Claude Code is installed on this machine
Best path if you're setting up OpenClaw for the first time. The wizard walks you through everything.
Option B: Generate + paste on the same machine
If Claude Code CLI is installed on the same machine as OpenClaw, generate the token and feed it directly:
# Generate the setup-token
claude setup-token
# Then pass it to OpenClaw
openclaw models auth setup-token --provider anthropic
Option C: Paste from a different machine (most common)
You generated the token on your laptop but OpenClaw runs on a remote server:
# On your server, paste the token you copied from Step 2
openclaw models auth paste-token --provider anthropic
⚙️ Step 4: Configure Your Model
In your openclaw.json5, set your default model:
{
agents: {
defaults: {
model: {
primary: "anthropic/claude-opus-4-6"
}
}
}
}
Available models with your subscription:
| Model | Best For |
|---|---|
anthropic/claude-opus-4-6 |
Most capable — complex reasoning, orchestration, analysis |
anthropic/claude-sonnet-4-5 |
Fast and capable — great balance for most tasks |
✅ Step 5: Verify the Connection
# Check that Anthropic shows up with valid credentials
openclaw models status
# Detailed view with auth profile info
openclaw models status --json
You should see:
- Anthropic provider listed as active
- An auth profile with a valid expiry date
- Your chosen model available
🎛️ Configuration Options
Thinking Mode (Claude 4.6)
Claude 4.6 defaults to adaptive thinking in OpenClaw. Override in config or per-message:
// In openclaw.json5
{
agents: {
defaults: {
models: {
"anthropic/claude-opus-4-6": {
params: {
thinking: "adaptive" // or "on", "off"
}
}
}
}
}
}
// Per-message: /think:on or /think:off
👥 Multiple Accounts
Separate agents (recommended)
For completely isolated credentials (personal vs work):
openclaw agents add work
openclaw agents add personal
# Then run onboarding for each agent separately
Multiple profiles in one agent (advanced)
Switch between profiles per-session:
/model Opus@anthropic:work
🔍 Troubleshooting
401 errors / token suddenly invalid
Setup-token auth can expire or be revoked by Anthropic.
# Re-generate the token
claude setup-token
# Paste it into OpenClaw
openclaw models auth paste-token --provider anthropic
# Restart the gateway
openclaw gateway restart
"No API key found for provider anthropic"
Auth is per agent. New agents don't inherit the main agent's keys.
# Re-run onboarding for that agent, or paste a token
openclaw models auth paste-token --provider anthropic
"OAuth token refresh failed"
The subscription token expired or was revoked.
# Generate a fresh token
claude setup-token
# Paste it
openclaw models auth paste-token --provider anthropic
# Restart
openclaw gateway restart
"No available auth profile (all in cooldown)"
# Check what's happening
openclaw models status --json
# Look for auth.unusableProfiles
# Add another profile or wait for cooldown
🔴 The Honest Risk Assessment
Read This
OpenClaw is middleware. It uses Anthropic's models through their API. When you use a setup-token, you're routing your Claude subscription through software that Anthropic didn't build and doesn't endorse.
What's happened before: Anthropic has restricted subscription usage outside of Claude Code for some users. If they tighten enforcement, your setup-token could stop working overnight.
What that means: If you build your entire operation on subscription auth and Anthropic blocks it, your agents go offline until you switch to API keys (pay-per-token).
The practical reality: Many people use setup-tokens today without issues. It works. Just understand the risk and have a plan B.
Quick Decision
| If you... | Do this |
|---|---|
| Are exploring, learning, building for yourself | Setup-token is fine (flat rate is cheaper) |
| Run a business or serve clients | Consider API keys as backup |
| Want zero risk | API key only (console.anthropic.com) |