okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8667a3dbf
main
1/** 2* The address an app is given depends on who builds the final request URL. 3* 4* OpenAI-style clients (Chat Completions, Responses) are given the base that ends in /v1 and add /chat/completions or /responses. 5* Anthropic-style clients (Claude Code, the Anthropic SDKs) add /v1/messages themselves, so they are given the server root. With 6* the /v1 base they post /v1/v1/messages. 7*/ 8export type ConnectProtocol = 'openai' | 'responses' | 'anthropic' ; 9 10/** The server root: the base address without its trailing /v1. */ 11export function serverRoot ( baseUrl :string ) :string { 12return String ( baseUrl ?? '' ). trim (). replace ( / \/+$ / , '' ). replace ( / \/v1$ / i , '' ); 13} 14 15/** The address to type into an app that speaks this protocol. */ 16export function appBaseUrl ( baseUrl :string , protocol :ConnectProtocol ) :string { 17return protocol === 'anthropic' ?serverRoot ( baseUrl ) :String ( baseUrl ?? '' ). trim (). replace ( / \/+$ / , '' ); 18}