anthropic testConnection: 토큰이 드는 메시지 호출 대신 모델 목록 조회로

/api/status가 주기적으로 부르는데 매번 haiku에 실제 메시지를 보내고 있었다. GET /v1/models?limit=1(과금 없음, 8초 제한)로 키와 네트워크만 확인한다.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-31 11:17:36 +09:00
1 parent 2073ab1ec8
commit 84bf2e7016
1 file changed
+5 -5
+5 -5
View File
@@ -125,13 +125,13 @@ export class AnthropicAdapter implements LLMProvider {
}
async testConnection(): Promise<boolean> {
// /api/status가 주기적으로 부르므로 토큰이 드는 메시지 호출 대신 모델 목록 조회(과금 없음)로 키·네트워크만 확인한다
try {
await this.post('/v1/messages', {
model: 'claude-haiku-5-5',
max_tokens: 1,
messages: [{ role: 'user', content: 'hi' }],
const response = await fetch(`${this.endpoint}/v1/models?limit=1`, {
headers: { 'x-api-key': this.apiKey, 'anthropic-version': '2023-06-01' },
signal: AbortSignal.timeout(8_000),
});
return true;
return response.ok;
} catch {
return false;
}