From 22784ece8d95a1ee3eed1ef83e34b06f6fb26471 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 17 Sep 2025 22:08:46 +0530 Subject: [PATCH] fix: append /v1 to ollama in openai-adapters --- packages/openai-adapters/src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 622482eee..201f67970 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -141,6 +141,15 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { case "lmstudio": return openAICompatible("http://localhost:1234/", config); case "ollama": + // for openai compaitability, we need to add /v1 to the end of the url + // this is required for cli (for core, endpoints are overriden by core/llm/llms/Ollama.ts) + if (config.apiBase && !config.apiBase.endsWith("v1")) { + if (config.apiBase.endsWith("/")) { + config.apiBase += "v1/"; + } else { + config.apiBase += "/v1/"; + } + } return openAICompatible("http://localhost:11434/v1/", config); case "mock": return new MockApi();