fix(test): use POST /v1/messages to validate anthropic-compatible connections#1916
Open
rehanchrl wants to merge 1 commit into
Open
fix(test): use POST /v1/messages to validate anthropic-compatible connections#1916rehanchrl wants to merge 1 commit into
rehanchrl wants to merge 1 commit into
Conversation
…nections GET /models is not a standard Anthropic API endpoint and many compatible proxies (e.g. Alibaba MaaS) do not implement it, causing the connection test to always return red even with a valid API key. Switch to POST /v1/messages with max_tokens=1 — the same approach used for the built-in anthropic provider — and treat any non-401/403 response as valid, since the provider may return 400/529 on minimal payloads but that still confirms the key is accepted. Uses connection.defaultModel when set so the test respects the configured model rather than always falling back to claude-3-haiku-20240307.
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
The connection test for
anthropic-compatibleproviders usesGET /modelsto validate API keys:GET /modelsis not part of the Anthropic API spec. Many compatible proxies don't implement it, so it returns a 404 — causing the dashboard indicator to always show red even when the key and endpoint are valid.Fix
Switch to
POST /v1/messageswithmax_tokens: 1, matching what the built-inanthropicprovider already does for its own connection test. Treat any response that isn't 401 or 403 as valid — a 400 or 529 still confirms the key was accepted.Also uses
connection.defaultModelwhen set, so the test respects the configured model instead of always hardcodingclaude-3-haiku-20240307.Relation to #1892
PR #1892 fixes the same issue for the built-in
anthropicprovider (addingbaseUrloverride support). This PR fixes the parallelanthropic-compatiblebranch which was missed.Test
Tested against a self-hosted Anthropic-compatible proxy — connection test now returns green with a valid key.