"Invalid bearer token" when using Anthropic API
Describe the bug
When using Anthropic API with the API key correctly added, below error message appears:
Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'Invalid bearer token'}}
My API key has been tested to work in other places.
Expected behavior
The newly added Anthropic instance should work.
Screenshots
Debugging information
$ flatpak run com.jeffser.Alpaca
/app/lib/python3.12/site-packages/pydbus/registration.py:130: DeprecationWarning: Gio.DBusConnection.register_object is deprecated
ids = [bus.con.register_object(path, interface, wrapper.call_method, None, None) for interface in interfaces]
INFO [main.py | main] Alpaca version: 6.0.3
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:802: FINISHME: support YUV colorspace with DRM format modifiers
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:834: FINISHME: support more multi-planar formats with DRM modifiers
INFO [_client.py | _send_single_request] HTTP Request: GET https://api.anthropic.com/v1/models "HTTP/1.1 401 Unauthorized"
ERROR [instance_manager.py | get_local_models] Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'Invalid bearer token'}}
Same exact problem here
$ flatpak info com.jeffser.Alpaca
Alpaca - Chat with AI models
ID: com.jeffser.Alpaca
Ref: app/com.jeffser.Alpaca/x86_64/stable
Arch: x86_64
Branch: stable
Version: 6.0.3
License: GPL-3.0-or-later
Origin: flathub
Collection: org.flathub.Stable
Installation: system
Installed: 1.8 GB
Runtime: org.gnome.Platform/x86_64/48
Sdk: org.gnome.Sdk/x86_64/48
Commit: 894f83ac5717079472783d457ab6ccc1afd935e1e9eb6e16c4547864…
Parent: 883e5b074f29edfaaee11901f902648ba533d26c535f9b4a6a2010cc…
Subject: Bug Fixes (6.0.3) (49346850)
Date: 2025-04-14 02:00:51 +0000
I think I found the issue. Calls are to anthropic do not contain the expected headers. Currently, alpaca uses the Authorization: Bearer some-api-key method. However, account to the anthropic docs, the expected header is x-api-key some-api-key.
I am working on a fix, will see if I can get the patch merged.
Alpaca does not use Authorization: Bearer API explicitly, most instances including Anthropic are managed using OpenAI's libraries
I probably will just remove compatibility with Anthropic
As in removing Anthropic as an option completely? That would be a pity... it's quite a big provider.
Hi everyone, I didn't end up removing Anthropic and instead waited to see if they would support OpenAI's sdk directly.
It seems like they have been supporting it for quite a bit so I'm going to close this issue, if there are still problems please tell me and I'll see what I can do.
Still persists.
Same here
same