Files
goodbuddy/src/main/agent/anthropic-endpoint.ts
T
2026-08-07 10:45:01 +08:00

16 lines
503 B
TypeScript

export function createAnthropicApiBaseUrl(baseUrl: string): string {
const url = new URL(baseUrl)
const path = url.pathname.replace(/\/+$/, '')
url.pathname = path.endsWith('/v1') ? path : `${path}/v1`
url.hash = ''
return url.toString()
}
export function createAnthropicMessagesUrl(baseUrl: string): URL {
const url = new URL(baseUrl)
const path = url.pathname.replace(/\/+$/u, '')
url.pathname = `${path.endsWith('/v1') ? path : `${path}/v1`}/messages`
url.hash = ''
return url
}