okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-int (a3024ed10) into f-split-qa1: qa2's s3237-s3238 kept, my 21 strings renumbered s3260-s32808667a3dbf

main
634 B12 linesraw
1/**
2 * Anthropic clients add `/v1/messages` to the base URL themselves, so the base URL they are given is the server root (no `/v1`).
3 * A base URL copied from an OpenAI-style setup ends in `/v1`, and the client then posts `/v1/v1/messages`. That one path means the
4 * same as the real one; nothing else is aliased (an OpenAI client never adds `/v1` on its own).
5 */
6const ALIASES = new Map([['/v1/v1/messages', '/v1/messages'], ['/v1/v1/messages/count_tokens', '/v1/messages/count_tokens']]);
7
8export function apiPath(path) {
9  const clean = path.length > 1 ? path.replace(/\/+$/, '') : path;
10  return ALIASES.get(clean) ?? path;
11}
12