#401 issues

1 messages Β· Page 1 of 1 (latest)

soft condorBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> βœ… Mark Solution

fringe loom
#

@mighty terrace

mighty terraceBOT
#

The HTTP 401 authentication error with "Invalid bearer token" typically means the API key for your model provider is missing, invalid, or expired.

Quick diagnostics to run:

# Check model auth status
clawdbot models status

# Full diagnosis
clawdbot doctor

# Check if env vars are loaded
clawdbot status --all

Common causes & fixes:

#
  1. Missing API key β€” Ensure your provider's API key is set in ~/.clawdbot/.env or as an environment variable:

    • OpenAI: OPENAI_API_KEY="sk-..."
    • Anthropic: ANTHROPIC_API_KEY="..."
    • OpenRouter: OPENROUTER_API_KEY="..."
  2. Restart required β€” After adding/changing env vars, restart the gateway:

    clawdbot gateway restart
    # or if using daemon
    clawdbot daemon restart
    
  3. Expired/invalid key β€” Generate a new API key from your provider's dashboard and update the config.

  4. Wrong credential type β€” Some providers (like Anthropic) require specific auth methods. If using Claude Code, you may need to run claude setup-token or use an API key instead.

Key docs:

mighty terraceBOT
# fringe loom <@1457407575476801641>

Hey! To help fix the 401 auth error, I need to know:

What model are you using?

Run this command on your machine and paste the output:

clawdbot models status

Or share your model config:

clawdbot status --all | grep -A5 "model"

This will tell me which provider's API key needs to be fixed. 🦐

fringe loom
#

Nothign is showing in ~/.clawdbot/.env

mighty terraceBOT
#

Thanks for the details! You're using Anthropic with Claude Opus 4.5. The 401 error means one (or both) of your Anthropic tokens is invalid or expired.

Quick fix options:

Option 1: Generate a new Anthropic API Key

  1. Go to console.anthropic.com
  2. Create a new API key
  3. Update it in your config:
clawdbot models auth paste-token --provider anthropic
  1. Restart the gateway:
clawdbot daemon restart
# or
clawdbot gateway restart
#

Option 2: Re-run Claude setup-token (if using Claude Code)

claude setup-token
clawdbot models status
clawdbot daemon restart

Option 3: Check which token is actually in use

Your output shows two tokens (anthropic:default and anthropic:manual). To see which one is active and test them:

# Check which profile has priority
clawdbot models auth order get --provider anthropic

# Test a specific profile
clawdbot models status --check
#

Most likely cause: The Anthropic token was revoked or expired. Anthropic API keys don't expire, but Claude Code tokens (sk-ant-...) can expire or get revoked if the subscription changes.

Try Option 1 first β€” generate a fresh API key from Anthropic's console and paste it in. 🦐

fringe loom
#

if im using cladue code max do i need the API key? Or just the set up toek nfor claude code

mighty terraceBOT
#
clawdbot models status
clawdbot doctor
  1. Restart:
clawdbot daemon restart

If claude setup-token says "not available" or gives errors:

  • Make sure Claude Code CLI is installed: claude --version
  • You need an active Claude Max or Pro subscription
  • If still stuck, use an Anthropic API key instead (more reliable)

Quick test:

#
# See which profile is active
clawdbot models status

If you still get 401s after regenerating the setup-token, I'd recommend switching to an Anthropic API key instead β€” it's more stable for API usage. 🦐

fringe loom
#

🦞 Clawdbot 2026.1.24-3 (885167d)
Gateway onlineβ€”please keep hands, feet, and appendages inside the shell at all times.
Config : ~/.clawdbot/clawdbot.json
Agent dir : ~/.clawdbot/agents/main/agent
Default : anthropic/claude-opus-4-5
Fallbacks (0) : -
Image model : - Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5 Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (1): anthropic (2)

  • anthropic effective=profiles:~/.clawdbot/agents/main/agent/auth-profiles.json | profiles=2 (oauth=0, token=2, api_key=0) | anthropic:default=token:sk-ant-o...aq3Jw7xQ, anthropic:manual=token:sk-ant-o...am5TdThA

OAuth/token status

  • anthropic
    • anthropic:default static - anthropic:manual static
mighty terraceBOT
#
# Clear the old profile
clawdbot models auth order clear --provider anthropic

# Add fresh token
claude setup-token
clawdbot models status
clawdbot daemon restart

If claude setup-token fails or isn't available:

  • Install Claude Code: npm install -g @anthropic-ai/claude-code
  • Or just use an Anthropic API key instead (more reliable):
    clawdbot models auth paste-token --provider anthropic
    
#

The key point: your current tokens are invalid (hence 401). Regenerating the setup-token is what fixes this. 🦐

fringe loom
#

🦞 Clawdbot 2026.1.24-3 (885167d)
Gateway onlineβ€”please keep hands, feet, and appendages inside the shell at all times.
Config : ~/.clawdbot/clawdbot.json
Agent dir : ~/.clawdbot/agents/main/agent
Default : anthropic/claude-opus-4-5
Fallbacks (0) : -
Image model : - Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5 Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (1): anthropic (2)

  • anthropic effective=profiles:~/.clawdbot/agents/main/agent/auth-profiles.json | profiles=2 (oauth=0, token=2, api_key=0) | anthropic:default=token:sk-ant-o...aq3Jw7xQ, anthropic:manual=token:sk-ant-o...am5TdThA

OAuth/token status

  • anthropic
    • anthropic:default static - anthropic:manual static
#

OKay i have done all of hte above I belive

#

I'm still getting the same error code when communicated to my bot via discord

mighty terraceBOT
#

# Force sync
clawdbot models status
clawdbot doctor

# Restart gateway
clawdbot daemon restart
  1. Verify the new token:
clawdbot models status | grep -A5 "anthropic"

If claude setup-token isn't working (not installed, no TTY, etc.), just use an API key instead β€” it's more reliable:

#
# Get API key from https://console.anthropic.com/settings/keys
clawdbot models auth paste-token --provider anthropic
clawdbot daemon restart

Which option works for you? 🦐

fringe loom
#

🦞 Clawdbot 2026.1.24-3 (885167d)
If it's repetitive, I'll automate it; if it's hard, I'll bring jokes and a rollback plan.
Config : ~/.clawdbot/clawdbot.json Agent dir : ~/.clawdbot/agents/main/agent Default : anthropic/claude-opus-4-5 Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5 Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): - Missing auth

  • anthropic Run claude setup-token or clawdbot configure.
    OAuth/token status
  • none
#

None have worked

fringe loom
#

@mighty terrace none of this worked

mighty terraceBOT
# fringe loom <@1457407575476801641> none of this worked

Let's diagnose this properly.

First, run these diagnostics and paste the output:

# Full status with provider probes
clawdbot status --deep

# Check if gateway can actually reach Anthropic
clawdbot doctor

# Show which credential is being used
clawdbot models status

# Check for env var conflicts
clawdbot status --all | grep -i anthropic
#

Also answer these:

  1. Is the Claude Code CLI installed? (claude --version)
  2. Are you running these commands on the same machine where the gateway is running?
  3. When you run claude setup-token, what happens? Does it succeed?
  4. Do you have an Anthropic API key you could try instead?

Quick nuclear option if all else fails:

# Stop gateway
clawdbot daemon stop

# Clear ALL auth
rm -rf ~/.clawdbot/agents/main/agent/auth-profiles.json
#
# Fresh start
clawdbot models auth paste-token --provider anthropic
# (paste your Anthropic API key when prompted)

# Restart
clawdbot daemon start

# Test
clawdbot models status --check

Paste the diagnostics and I'll pinpoint the issue. 🦐

fringe loom
#

Discord: ok (@Clarence) (676ms)
Agents: main (default) Heartbeat interval: 1h (main)
Session store (main): /Users/ryanbonner/.clawdbot/agents/main/sessions/sessions.json (2 entries)

  • agent:main:discord:channel:1466441323035889811 (35m ago)
  • agent:main:main (96m ago)
    Run "clawdbot doctor --fix" to apply changes.
    β”‚ β”” Doctor complete.

ryanbonner@Ryans-Mac-mini ~ % clawdbot models status

🦞 Clawdbot 2026.1.24-3 (885167d) β€” WhatsApp Business, but without the business.

Config : ~/.clawdbot/clawdbot.json
Agent dir : ~/.clawdbot/agents/main/agent
Default : anthropic/claude-opus-4-5
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5
Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): -

Missing auth

  • anthropic Run claude setup-token or clawdbot configure.

OAuth/token status

  • none
    ryanbonner@Ryans-Mac-mini ~ % clawdbot status --all | grep -i anthropic
    2026-01-29T15:31:07.352Z [reload] config change requires gateway restart (meta.lastTouchedAt, auth.profiles.anthropic:manual)
    2026-01-29T16:12:38.426Z [gateway] agent model: anthropic/claude-opus-4-5
mighty terraceBOT
# fringe loom

I need to see the model auth status specifically. Run:

clawdbot models status

And also check the recent logs for the 401 error:

clawdbot logs --limit 50 | grep -i "401\|anthropic\|auth\|error"

Paste both outputs β€” the first will show which tokens are loaded, and the second will show the actual error. 🦐

fringe loom
#

ryanbonner@Ryans-Mac-mini ~ % clawdbot models status

🦞 Clawdbot 2026.1.24-3 (885167d) β€” WhatsApp Business, but without the business.

Config : ~/.clawdbot/clawdbot.json
Agent dir : ~/.clawdbot/agents/main/agent
Default : anthropic/claude-opus-4-5
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5
Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): -

Missing auth

  • anthropic Run claude setup-token or clawdbot configure.

OAuth/token status

  • none
    ryanbonner@Ryans-Mac-mini ~ % clawdbot status --all | grep -i anthropic
    2026-01-29T15:31:07.352Z [reload] config change requires gateway restart (meta.lastTouchedAt, auth.profiles.anthropic:manual)
    2026-01-29T16:12:38.426Z [gateway] agent model: anthropic/claude-opus-4-5
mighty terraceBOT
#
clawdbot models status
clawdbot daemon restart

Option 2: Paste an Anthropic API key

# Get key from https://console.anthropic.com/settings/keys
clawdbot models auth paste-token --provider anthropic
# Paste your API key when prompted
clawdbot daemon restart

Option 3: Run the onboarding wizard

clawdbot onboard
#
# Choose Anthropic and authenticate
clawdbot daemon restart

Also: The logs show a pending config change that requires restart:

config change requires gateway restart

After adding auth, always run:

clawdbot daemon restart

Which auth method do you prefer? 🦐

fringe loom
#

I'm doing option 1

mighty terraceBOT
# fringe loom I'm doing option 1

Perfect! Here's what to run:

# Step 1: Generate the setup-token
claude setup-token

# Step 2: Verify it was synced
clawdbot models status

# Step 3: Restart the gateway
clawdbot daemon restart

# Step 4: Test it
clawdbot models status --check

Important:

#
  • claude setup-token requires an interactive TTY ( Terminal window)
  • Make sure Claude Code CLI is installed first: npm install -g @anthropic-ai/claude-code
  • You need an active Claude Max or Pro subscription

Run those commands and paste the outputs β€” especially if claude setup-token fails or if clawdbot models status still shows "Missing auth" after. 🦐

fringe loom
#

so the first oen it sets up the token and i use export CLAUDE_CODE_OAUTH_TOKEN=<tokenitgave>

But when i run
Clawdbot models status it gives the following

ryanbonner@Ryans-Mac-mini ~ % clawdbot models status

🦞 Clawdbot 2026.1.24-3 (885167d) β€” Ah, the fruit tree company! 🍎

Config : ~/.clawdbot/clawdbot.json
Agent dir : ~/.clawdbot/agents/main/agent
Default : anthropic/claude-opus-4-5
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (1) : opus -> anthropic/claude-opus-4-5
Configured models (1): anthropic/claude-opus-4-5

Auth overview
Auth store : ~/.clawdbot/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (0): -

Missing auth

  • anthropic Run claude setup-token or clawdbot configure.

OAuth/token status

  • none
mighty terraceBOT
# fringe loom so the first oen it sets up the token and i use export CLAUDE_CODE_OAUTH_TOKEN=<...

Ah, I see the issue! claude setup-token shouldn't give you an export command β€” it should authenticate and store credentials automatically.

The export method isn't how Clawdbot reads the token. It expects the token to be in Claude Code's credential store (~/.claude/.credentials.json or Keychain on macOS).

Easier fix: Use an Anthropic API key directly

# Get a key from https://console.anthropic.com/settings/keys
clawdbot models auth paste-token --provider anthropic

When prompted, paste your full Anthropic API key (starts with sk-...).

Then:

clawdbot daemon restart
#
clawdbot models status --check

If you really want to use Claude Code setup-token:
Make sure you have the latest version and it's completing the full auth flow:

# Check version
claude --version

# Reinstall if needed
npm install -g @anthropic-ai/claude-code

# Run it interactively (needs a proper terminal, not SSH/exec)
claude setup-token
#

But honestly, the API key method is more reliable. Try that first! 🦐

fringe loom
#

i have claude max im not goign to use API

#

2.1.23 (Claude Code)

#

Okay just ran claude setup-token and it gave me

Your OAuth token (Valid for 1 year):
<token>

mighty terraceBOT
# fringe loom i have claude max im not goign to use API

Got it β€” let's get claude setup-token working properly.

First, verify Claude Code is installed correctly:

# Check if it's installed
which claude
claude --version

If not installed or outdated:

npm install -g @anthropic-ai/claude-code

Now the key point: claude setup-token must run in an interactive terminal (not over SSH, not in a script, not via exec). It needs to open a browser for OAuth.

#

If you're already in a proper Terminal.app window:

claude setup-token

This should:

  1. Open a browser for authentication
  2. Complete the OAuth flow
  3. Store the token in Keychain (macOS)

After it completes:

clawdbot models status
clawdbot daemon restart
clawdbot models status --check
#

If claude setup-token still gives you an export command instead of completing auth:

  • You're likely not in a proper interactive TTY
  • Try opening a fresh Terminal window and run it there
  • Or use screen/tmux for a full interactive session

Let me know what happens when you run claude setup-token in a fresh terminal! 🦐

mighty terraceBOT
# fringe loom 2.1.23 (Claude Code)

Claude Code 2.1.23 is installed β€” good!

The problem is claude setup-token needs a real interactive terminal with a display (to open a browser for OAuth).

Do this:

  1. Open a new Terminal.app window (not SSH, not via clawdbot exec)
  2. Run directly in that window:
    claude setup-token
    
  3. It should open a browser and complete authentication
  4. Then check in that same terminal:
    clawdbot models status
    
  5. Restart the gateway:
#
   clawdbot daemon restart

The key is running it in a fresh Terminal window where you can interact with the browser OAuth flow. Let me know if it prompts for browser auth! 🦐

mighty terraceBOT
# fringe loom Okay just ran claude setup-token and it gave me Your OAuth token (Valid for 1 y...

That's the fallback behavior when it can't store the token automatically. Now we need to get that token into Clawdbot.

Try this:

# Set the token as an environment variable
export CLAUDE_CODE_OAUTH_TOKEN="<token>"

# Enable shell env in clawdbot config so it picks it up
clawdbot config patch --json '{"env": {"shellEnv": true, "CLAUDE_CODE_OAUTH_TOKEN": "'<token>'"}}'

# Restart the gateway
clawdbot daemon restart

# Verify
clawdbot models status
#

Alternative: Use the paste-token method

clawdbot models auth paste-token --provider anthropic
# Paste the entire token (not just sk-ant-..., the full thing)

Let me know which works, or if you get errors! 🦐

outer jay
fringe loom
#

idk shits not working right now

mighty terraceBOT
# outer jay how do you get your claude max to work with clawdbot?

Great question! Here's the clean way to get Claude Max working with Clawdbot:

Option 1: Use Anthropic API Key (Recommended)

Claude Max includes API access, but you need to generate a key separately:

  1. Go to https://console.anthropic.com/settings/keys
  2. Click "Create Key" (yes, even with Max you need an API key for API access)
  3. Copy the key
  4. In terminal:
    clawdbot models auth paste-token --provider anthropic
    # Paste your key
    clawdbot daemon restart
    

Option 2: Use Claude Code CLI Token

#

If you insist on using the setup-token method:

  1. Open a fresh Terminal.app window (not SSH)
  2. Run:
    claude setup-token
    
  3. If it gives you an OAuth token string, run:
    clawdbot models auth paste-token --provider anthropic
    # Paste the full token it gave you
    clawdbot daemon restart
    

Why API Key is Better

  • More stable than setup-tokens
#
  • Works reliably across restarts
  • No TTY/interactive terminal requirements
  • Properly supported for API usage

Bottom line: Even with Claude Max, generate an API key from the Anthropic Console β€” it's the most reliable path for Clawdbot. 🦐

fringe loom
#

@mighty terrace

#

Okay just used option 1 and restarted daemon what next

mighty terraceBOT
#

Great question! I need to be honest here β€” I don't have full visibility on how Claude Max billing works with API keys.

What I do know:

  1. Claude Max primarily covers Claude Code CLI usage
  2. API access may or may not be included depending on your specific Max plan
  3. The API key draws from whatever billing source is configured in the Anthropic Console

What you should check:

Go to https://console.anthropic.com/settings/keys and:

  • See if your account shows API credits available
  • Check your billing section in the console

Most likely scenario:

  • If your Max plan includes API credits β†’ API key will use those
mighty terraceBOT
#
  • If not β†’ it may bill separately or show errors

Safest bet:

Check your Anthropic Console dashboard. If you see API credits available under your Max subscription, the API key method will work. If not, you may need to add a payment method or contact Anthropic support.

Bottom line: Try generating an API key first β€” if it works, you're good. If you get billing errors, you'll know the API credits weren't included in your Max plan. 🦐

#
  1. Go to your Discord server
  2. Send a message to the bot
  3. It should respond (no more 401 error)

If it still doesn't work:

# Check the logs for errors
clawdbot logs --limit 30 | grep -i "error\|401\|anthropic"

# Verify model is using the right auth
clawdbot models status --check

Try chatting with the bot now and let me know if it responds! 🦐

outer jay
mighty terraceBOT
# outer jay Nice! Ty! With Claude Max using the first approach with the API is it still pay ...

I don't have definitive visibility on Claude Max plan specifics β€” whether API access is included or pay-as-you-go depends on your exact Anthropic subscription tier.

Best way to check:

  1. Go to https://console.anthropic.com/
  2. Look at your billing/credits section
  3. Check if "API credits" are available under your Max subscription

General guidance:

  • Some Max tiers include API credits
  • Others treat API usage as pay-as-you-go
  • The only way to know for sure is to check your console or contact Anthropic support

If you're unsure:

  • Generate an API key and try a small test
  • Watch your Anthropic Console billing page
  • If it deducts credits, you're good; if it shows a billing error, you know API isn't included
#

Sorry I can't give a more definitive answer β€” billing specifics vary by Max plan. 🦐

outer jay
#

when I try to use anthropic model directly (not via openrouter) I get a tool_use block, any way around that?

mighty terraceBOT
# outer jay when I try to use anthropic model directly (not via openrouter) I get a tool_use...

I'm not 100% sure what you mean by "tool_use block" β€” could you share the exact error or message you're seeing?

Common causes:

  1. Model safety policy β€” Some Anthropic models refuse certain tool use requests
  2. Model tier β€” Sonnet 4 vs Opus 4 have different capabilities
  3. Prompt triggering filters β€” Certain request types get blocked

Quick things to try:

# Try a different Anthropic model
/configure --model anthropic/claude-sonnet-4-5
clawdbot daemon restart

Or:

#
# Check the actual error in logs
clawdbot logs --limit 50 | grep -i "block\|refuse\|tool"

What does the error/message actually say? (paste it)

That'll help me pinpoint whether it's a model restriction, safety filter, or something else. 🦐