Vibe Coding Academy | ClawdBot Auth Guide

Set Up ClawdBot (OpenClaw) Without an API Key

Stop paying for API keys. If you already have a Claude Pro or Max subscription, you can run ClawdBot (OpenClaw) for free. Here's exactly how.

Before You Start

Prerequisites

Make sure you have the following ready before starting:

A Cloud VPS Running Ubuntu/Linux with SSH access. If you don't have one yet, check out our VPS setup guide.
Claude Pro or Max Subscription $20–200/month from claude.ai/pricing. No API key needed.
A Local PC or Mac With a web browser — needed to generate the auth token.
Terminal Access SSH into your VPS from your PC or phone.
Step 1

Understand API Key vs Subscription Auth

There are two ways to authenticate Claude Code / ClawdBot:

Most guides tell you to use an API key — but if you already have a Pro or Max subscription, you're paying twice. The OAuth token method lets you use ClawdBot at no additional cost.

If you have an ANTHROPIC_API_KEY environment variable set, Claude Code will use it instead of your subscription — and you'll be charged API fees. Remove it to use your subscription.
This guide assumes you already have OpenClaw installed. If not, follow our ClawdBot setup guide first, then come back here to switch from API key to subscription auth.
Step 2

Generate Your Auth Token (On Your Local PC/Mac)

This step must be done on a machine with a web browser — not on your VPS.

Install Claude Code (if you haven't)

curl -fsSL https://claude.ai/install.sh | bash

Run the Token Generation Command

claude setup-token

Here's what happens:

This token is like a password. Don't share it publicly or commit it to a repository. Don't close the terminal until you've copied it.
Step 3

Apply the Token to Your VPS

SSH into your server:

ssh root@your-server-ip

Option A — Using OpenClaw's Built-in Command (Recommended)

openclaw models auth setup-token --provider anthropic

Paste the token when prompted.

Option B — Set Environment Variable Directly

export CLAUDE_CODE_OAUTH_TOKEN="your-token-here"

To make it permanent:

echo 'export CLAUDE_CODE_OAUTH_TOKEN="your-token-here"' >> ~/.bashrc
source ~/.bashrc
Option A is recommended because OpenClaw securely stores the token and manages it for you. Option B works but you'll need to update ~/.bashrc manually when the token expires.

Restart the Gateway

openclaw gateway restart
Step 4

Verify It's Working

Start OpenClaw if it's not already running:

openclaw gateway start

Or launch the TUI:

openclaw tui

Now test it:

Check your status:

openclaw status

This should show the model provider as Anthropic.

No API charges will appear on console.anthropic.com. Your usage is covered by your Pro/Max subscription.
Step 5

Refresh When the Token Expires

OAuth tokens expire periodically (usually every few weeks). When it happens, you'll see authentication errors in OpenClaw.

The fix takes 30 seconds:

  1. On your local PC/Mac, run: claude setup-token
  2. Copy the new token
  3. On your VPS, run: openclaw models auth setup-token --provider anthropic → paste the new token
  4. Restart the gateway: openclaw gateway restart
Pro Tip: If you're on mobile and can't run claude setup-token, you can SSH into your VPS from Termius and access any machine that has a browser to generate the token.
Step 6

Troubleshooting

"Claude Code is using my API key instead of my subscription"

Check if you have an API key set:

echo $ANTHROPIC_API_KEY

If it returns a value, remove it:

unset ANTHROPIC_API_KEY

Also remove it from ~/.bashrc if it's saved there, then reload:

source ~/.bashrc

"Token not working after setting environment variable"

Make sure you're using the correct variable name:

Restart your terminal session:

source ~/.bashrc

"Browser doesn't open on my VPS"

That's expected — your VPS has no browser. Run claude setup-token on your local PC/Mac, then transfer the token to your VPS.

"Authentication expired / 401 error"

Your token has expired. Follow Step 5 above to refresh it.

"openclaw models auth setup-token command not found"

Update OpenClaw to the latest version:

npm update -g openclaw@latest
Summary

Quick Reference

Local PC/Mac: Just run claude — the browser handles everything automatically.

VPS / Headless Server: Run claude setup-token locally → copy the token → run openclaw models auth setup-token --provider anthropic on your server.

Token Expired? Repeat the flow. Takes 30 seconds.

Cost: $0 extra — your Pro/Max subscription covers everything.
Related Guides

Continue Learning

Want to Learn More?

Join the Vibe Coding Academy community to learn how to build AI-powered apps, automate your workflow, and level up your skills.

Join the Academy
Abdul Khan
Written by
Abdul Khan