#55
"Invalid bearer token" when using Anthropic direct
What happened
I have set ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL as per the docs (in .env.local within .deepsec directory.
I get:
Agent SDK error: Claude Code returned an error result: Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"..."}Reproduction
pnpm deepsec process --project-id ...Expected vs actual
I expect the requests to work, they didn't.
Environment
- deepsec version (
pnpm deepsec --version): 1.1.14 - Node version (
node --version): v24.11.1 - OS: MacOS
- Agent backend (
claude-agent-sdk/codex): claude-agent-sdk - Model:
Logs
> Investigating 4 file(s) with Claude Agent SDK (claude-opus-4-7)
Turn 1 (107s, 0 tool calls)
Turn 1 (107s, 0 tool calls)
Turn 1 (110s, 0 tool calls)
Agent SDK error: Claude Code returned an error result: Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"req_,..."}
Agent SDK error: Claude Code returned an error result: Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"req_..."}
Agent SDK error: Claude Code returned an error result: Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"},"request_id":"req_..."}Activity
3Have you tried running claude with the same env vars and it worked?
Docs need to be updated, should be ANTHROPIC_API_KEY
Try setting your "ANTHROPIC_API_KEY" as your key instead of the "ANTHROPIC_AUTH_TOKEN" in your .env.local