Files
Niko1221 323a11e721 Connect app: the third tab and strata connect give the server root (no /v1); the server also accepts /v1/v1/messages
Messages-API clients (coding CLIs, the SDKs) add /v1/messages to their base URL themselves. The Connect dialog showed the OpenAI-style
base that ends in /v1, so those apps posted /v1/v1/messages and got a 404. The third tab now shows the root address with a
one-line note (the base-URL variable for coding CLIs), the other tabs keep /v1. strata connect cuts a pasted /v1 back to the root for
every app and says so for coding CLIs, and strata launch and the monitor's Connect view list the Messages-API address. The server (serve
and the app's host, plus the shared listener) reads /v1/v1/messages and /v1/v1/messages/count_tokens as the real paths; nothing else
is aliased. Tested with the real Python SDK client against the mock-engine server.
2026-10-18 20:40:33 +02:00

13 lines
634 B
JavaScript

/**
* Anthropic clients add `/v1/messages` to the base URL themselves, so the base URL they are given is the server root (no `/v1`).
* 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
* same as the real one; nothing else is aliased (an OpenAI client never adds `/v1` on its own).
*/
const ALIASES = new Map([['/v1/v1/messages', '/v1/messages'], ['/v1/v1/messages/count_tokens', '/v1/messages/count_tokens']]);
export function apiPath(path) {
const clean = path.length > 1 ? path.replace(/\/+$/, '') : path;
return ALIASES.get(clean) ?? path;
}