(baseURL)
| 1 | function getChatCompletionsUrl(baseURL) { |
| 2 | const root = (baseURL || "https://api.openai.com/v1").replace(/\/+$/, ""); |
| 3 | return `${root}/chat/completions`; |
| 4 | } |
| 5 | |
| 6 | export async function chat({ apiKey, baseURL, model, messages, tools }) { |
| 7 | const res = await fetch(getChatCompletionsUrl(baseURL), { |