Skip to content

fix(test): use POST /v1/messages to validate anthropic-compatible connections#1916

Open
rehanchrl wants to merge 1 commit into
decolua:masterfrom
rehanchrl:fix/anthropic-compatible-connection-test
Open

fix(test): use POST /v1/messages to validate anthropic-compatible connections#1916
rehanchrl wants to merge 1 commit into
decolua:masterfrom
rehanchrl:fix/anthropic-compatible-connection-test

Conversation

@rehanchrl

@rehanchrl rehanchrl commented Jun 19, 2026

Copy link
Copy Markdown

Problem

The connection test for anthropic-compatible providers uses GET /models to validate API keys:

const res = await fetchWithConnectionProxy(`${modelsBase}/models`, {
  headers: { "x-api-key": connection.apiKey, ... },
});
return { valid: res.ok, ... };

GET /models is 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/messages with max_tokens: 1, matching what the built-in anthropic provider 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.defaultModel when set, so the test respects the configured model instead of always hardcoding claude-3-haiku-20240307.

Relation to #1892

PR #1892 fixes the same issue for the built-in anthropic provider (adding baseUrl override support). This PR fixes the parallel anthropic-compatible branch which was missed.

Test

Tested against a self-hosted Anthropic-compatible proxy — connection test now returns green with a valid key.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant