#401 issues
1 messages Β· Page 1 of 1 (latest)
@mighty terrace
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:
-
Missing API key β Ensure your provider's API key is set in
~/.clawdbot/.envor as an environment variable:- OpenAI:
OPENAI_API_KEY="sk-..." - Anthropic:
ANTHROPIC_API_KEY="..." - OpenRouter:
OPENROUTER_API_KEY="..."
- OpenAI:
-
Restart required β After adding/changing env vars, restart the gateway:
clawdbot gateway restart # or if using daemon clawdbot daemon restart -
Expired/invalid key β Generate a new API key from your provider's dashboard and update the config.
-
Wrong credential type β Some providers (like Anthropic) require specific auth methods. If using Claude Code, you may need to run
claude setup-tokenor use an API key instead.
Key docs:
- Model providers: https://docs.moltbot.ai/providers
- Authentication troubleshooting: https://docs.moltbot.ai/gateway/authentication
- General troubleshooting: https://docs.moltbot.ai/gateway/troubleshooting
What model provider are you using? I can give more specific guidance once I know. π¦
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. π¦
Nothign is showing in ~/.clawdbot/.env
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
- Go to console.anthropic.com
- Create a new API key
- Update it in your config:
clawdbot models auth paste-token --provider anthropic
- 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. π¦
if im using cladue code max do i need the API key? Or just the set up toek nfor claude code
No, you don't need an API key if you're using Claude Code Max! The claude setup-token should work.
However, the 401 error means your current setup-token is either:
- Expired (Claude Code tokens can expire)
- Revoked (e.g., subscription changed)
- Not properly synced to Clawdbot
Fix:
- On the machine running the gateway, run:
claude setup-token
- Then sync it:
clawdbot models status
clawdbot doctor
- 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. π¦
π¦ 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
The tokens are still showing the same (invalid) ones. You need to regenerate your Claude Code token.
Run this on the machine running Clawdbot:
# 1. Regenerate the setup-token
claude setup-token
If that completes successfully, then check if Clawdbot picked it up:
clawdbot models status
If the tokens still show the old sk-ant-... ones, you may need to manually update:
# 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. π¦
π¦ 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
The old tokens are still cached. We need to force a refresh.
Step-by-step:
- Check what's actually in the auth file:
cat ~/.clawdbot/agents/main/agent/auth-profiles.json
- Delete the invalid tokens and re-sync:
# Remove the old auth file
rm ~/.clawdbot/agents/main/agent/auth-profiles.json
# Regenerate token (must be on gateway machine)
claude setup-token
# Force sync
clawdbot models status
clawdbot doctor
# Restart gateway
clawdbot daemon restart
- 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? π¦
π¦ 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-tokenorclawdbot configure.
OAuth/token status - none
None have worked
@mighty terrace 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:
- Is the Claude Code CLI installed? (
claude --version) - Are you running these commands on the same machine where the gateway is running?
- When you run
claude setup-token, what happens? Does it succeed? - 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. π¦
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-tokenorclawdbot 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
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. π¦
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-tokenorclawdbot 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
Found the problem! You have no Anthropic auth configured at all.
Missing auth
- anthropic Run `claude setup-token` or `clawdbot configure`.
The old tokens are gone, and nothing replaced them. That's why you're getting 401s.
Fix:
Choose ONE option:
Option 1: Use Claude Code setup-token (if Claude Code CLI is installed)
claude setup-token
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? π¦
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-tokenrequires 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. π¦
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-tokenorclawdbot configure.
OAuth/token status
- none
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! π¦
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>
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:
- Open a browser for authentication
- Complete the OAuth flow
- 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! π¦
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:
- Open a new Terminal.app window (not SSH, not via clawdbot exec)
- Run directly in that window:
claude setup-token - It should open a browser and complete authentication
- Then check in that same terminal:
clawdbot models status - 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! π¦
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! π¦
how do you get your claude max to work with clawdbot?
idk shits not working right now
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:
- Go to https://console.anthropic.com/settings/keys
- Click "Create Key" (yes, even with Max you need an API key for API access)
- Copy the key
- 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:
- Open a fresh Terminal.app window (not SSH)
- Run:
claude setup-token - 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. π¦
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:
- Claude Max primarily covers Claude Code CLI usage
- API access may or may not be included depending on your specific Max plan
- 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
Perfect! Now let's verify it's working:
# Check if auth is now configured
clawdbot models status
Look for:
Providers w/ OAuth/tokens (1): anthropic
- anthropic:default=token:sk-ant-...
If you see that, it's configured!
Then test it:
- 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. π¦
- Go to your Discord server
- Send a message to the bot
- 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! π¦
Nice! Ty! With Claude Max using the first approach with the API is it still pay as you go?
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:
- Go to https://console.anthropic.com/
- Look at your billing/credits section
- 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. π¦
when I try to use anthropic model directly (not via openrouter) I get a tool_use block, any way around that?
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:
- Model safety policy β Some Anthropic models refuse certain tool use requests
- Model tier β Sonnet 4 vs Opus 4 have different capabilities
- 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. π¦