fix(models): use x-api-key for Anthropic API probing#13189
fix(models): use x-api-key for Anthropic API probing#13189cedric-common wants to merge 1 commit into
Conversation
probe_api_models() unconditionally sends Authorization: Bearer to every endpoint. Anthropic's native API (api.anthropic.com) rejects Bearer tokens and requires x-api-key + anthropic-version headers. This was previously masked because detect_provider_for_model() silently rerouted Anthropic requests to OpenRouter (fixed in f2f9d0c). Now that direct provider routing is respected, the probing mismatch surfaces as a 401 and blocks native Anthropic usage. Fix: detect api.anthropic.com in probe_api_models() and swap the auth headers before making the /models request.
✅ Review Complete - LGTMTested - all 49 Anthropic provider tests passing Test Results
Detailed AnalysisAnthropic x-api-key fix ✅
Test coverage ✅
Impact ✅
RecommendationMerge immediately. This fix:
No additional changes needed. Ready for merge. Reviewer: @teknium1 |
1 similar comment
|
Thanks @cedric-common. Closing — subsumed by @Wangshengyang2004's #12950 which landed in #15136 (commit 647900e). Your URL-based detection ( Both contributors identified the right problem — thanks for the report. |
Problem
🐛 Describe the bug
detect_provider_for_model() silently rerouted Anthropic requests to OpenRouter (fixed in #10300 / f2f9d0c). Now that direct provider routing is respected, unconditionally sends to every endpoint. Anthropic's native API () rejects Bearer tokens and returns HTTP 401, which blocks native Anthropic usage entirely.
Reproduction
Fix
Detect in and swap the auth headers before making the request:
Checklist
Closes the latent probing issue exposed by #10300.