diff --git a/src/commands/onboard-custom.ts b/src/commands/onboard-custom.ts index 2ab5de416a..f9e8ae84b6 100644 --- a/src/commands/onboard-custom.ts +++ b/src/commands/onboard-custom.ts @@ -313,8 +313,14 @@ async function requestAnthropicVerification(params: { apiKey: string; modelId: string; }): Promise { + // Use a base URL with /v1 injected for this raw fetch only. The rest of the app uses the + // Anthropic client, which appends /v1 itself; config should store the base URL + // without /v1 to avoid /v1/v1/messages at runtime. See docs/gateway/configuration-reference.md. + const baseUrlForRequest = /\/v1\/?$/.test(params.baseUrl.trim()) + ? params.baseUrl.trim() + : params.baseUrl.trim().replace(/\/?$/, "") + "/v1"; const endpoint = resolveVerificationEndpoint({ - baseUrl: params.baseUrl, + baseUrl: baseUrlForRequest, modelId: params.modelId, endpointPath: "messages", });