fix(llama-cpp): route to configured local baseUrl instead of OpenAI (#3136) (#3161)

llama-cpp was missing from the local-provider group in buildUrl(), so it
fell through to the OpenAI baseUrl and returned an OpenAI 401. Add the
case to resolve the connection's providerSpecificData.baseUrl.

Co-authored-by: tjengbudi <tjengbudi@users.noreply.github.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-04 16:57:45 -03:00
committed by GitHub
parent 58a9573904
commit a2fd56c313
2 changed files with 21 additions and 0 deletions

View File

@@ -205,6 +205,7 @@ export class DefaultExecutor extends BaseExecutor {
const baseUrl = credentials?.providerSpecificData?.baseUrl || this.config.baseUrl;
return normalizeOpenAIChatUrl(baseUrl);
}
case "llama-cpp":
case "lm-studio":
case "modal":
case "reka":

View File

@@ -0,0 +1,20 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { DefaultExecutor } from "@omniroute/open-sse/executors/default.ts";
// Regression for issue #3136: a `llama-cpp` local provider connection must send
// requests to the user's configured local baseUrl, not OpenAI's API. Before the
// fix, `llama-cpp` was missing from the local-provider case group in buildUrl(),
// so it fell through to the registry/default path and (because llama-cpp is not
// in the registry → DefaultExecutor falls back to PROVIDERS.openai) resolved to
// https://api.openai.com/v1/... — producing OpenAI-worded 401 "no api key" errors.
test("llama-cpp buildUrl routes to the configured local baseUrl, not OpenAI", () => {
const executor = new DefaultExecutor("llama-cpp");
const url = executor.buildUrl("some-model", true, 0, {
providerSpecificData: { baseUrl: "http://127.0.0.1:8080/v1" },
});
assert.equal(url, "http://127.0.0.1:8080/v1/chat/completions");
assert.ok(!url.includes("api.openai.com"), `expected local URL, got ${url}`);
});