UNPKG

@bitkyc08/opencodex

Version:

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code

12 lines (10 loc) • 489 B
const TRAILING_SLASHES = /\/+$/; const TRAILING_CHAT_COMPLETIONS = /\/chat\/completions\/?$/; /** Build the openai-chat send URL from a configured baseUrl. * Accepts /v1, /v1/, /v1/chat/completions, and /v1/chat/completions/. */ export function openaiChatCompletionsUrl(baseUrl: string): string { const trimmed = baseUrl.trim().replace(TRAILING_SLASHES, ""); const withoutEndpoint = trimmed.replace(TRAILING_CHAT_COMPLETIONS, ""); return `${withoutEndpoint}/chat/completions`; }