fix(auth): use bearer auth for MiniMax Anthropic endpoints - #4002
Closed
kshitijk4poor wants to merge 1 commit into
Closed
fix(auth): use bearer auth for MiniMax Anthropic endpoints#4002kshitijk4poor wants to merge 1 commit into
kshitijk4poor wants to merge 1 commit into
Conversation
Contributor
|
Merged via #4028 onto current main. Cherry-picked with authorship preserved. Fixed 3 test values that had display-tool redaction artifacts. MiniMax Anthropic endpoints now correctly use Bearer auth. Thanks @kshitijk4poor! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MiniMax's Anthropic-compatible
/anthropicendpoints were failing with HTTP 401 authentication errors in Hermes gateway sessions even whenMINIMAX_API_KEYwas configured correctly.The user-visible failure matched MiniMax's auth error exactly:
login fail: Please carry the API secret key in the 'Authorization' field of the request headerThis broke Telegram and Discord replies for MiniMax-backed sessions.
Root Cause
Hermes routes MiniMax through
anthropic_messagesmode, butbuild_anthropic_client()inferred auth mode only from Anthropic token shape:x-api-keyMiniMax is Anthropic-compatible at the message API layer, but not at the auth layer. Its
/anthropicendpoints expect regular API keys viaAuthorization: Bearer ..., not Anthropic's nativex-api-keyheader.Because MiniMax secrets do not use Anthropic's
sk-ant-apiprefix, Hermes could also misclassify them as Anthropic OAuth/setup tokens and attach Claude Code OAuth headers that do not belong on MiniMax requests.Fix
_requires_bearer_auth()to detect Anthropic-compatible providers that require bearer auth/anthropicendpoints throughauth_tokeninstead ofapi_keyTesting
uv run --with pytest --with pytest-xdist python -m pytest tests/test_anthropic_adapter.py tests/test_run_agent.py -q -k 'anthropic or minimax'Research Notes
Checked the adjacent ecosystem before patching:
Authorization: Bearer <key>for ChatCompletion v2 requestsbkerf/claude-code-multiconfigures MiniMax withauth_tokenMiniMax-AI/Mini-Agentexplicitly setsAuthorization: Bearer {api_key}even when using Anthropic's SDK