Merge pull request #1597 from zzh-github/feature/openai-compatible-raw

Add raw OpenAI-compatible provider without /v1 normalization
This commit is contained in:
Rohan Verma 2026-07-13 13:02:19 -07:00 committed by GitHub
commit d1fa9306cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 1 deletions

View file

@ -87,6 +87,15 @@ REGISTRY: dict[str, ProviderSpec] = {
"bearer", "bearer",
"OpenAI-compatible provider", "OpenAI-compatible provider",
), ),
"openai_compatible_raw": ProviderSpec(
Transport.NATIVE,
"openai",
"none",
None,
True,
"bearer",
"OpenAI-compatible raw endpoint",
),
"lm_studio": ProviderSpec( "lm_studio": ProviderSpec(
Transport.OPENAI_COMPATIBLE, Transport.OPENAI_COMPATIBLE,
"openai", "openai",

View file

@ -64,6 +64,22 @@ def test_openai_compatible_resolver_uses_explicit_api_base() -> None:
assert ensure_v1("http://example.com/v1") == "http://example.com/v1" assert ensure_v1("http://example.com/v1") == "http://example.com/v1"
def test_openai_compatible_raw_resolver_does_not_append_v1() -> None:
model, kwargs = to_litellm(
{
"provider": "openai_compatible_raw",
"base_url": "https://ark.cn-beijing.volces.com/api/v3",
"api_key": "ark-key",
"extra": {},
},
"ep-20260101000000-test",
)
assert model == "openai/ep-20260101000000-test"
assert kwargs["api_base"] == "https://ark.cn-beijing.volces.com/api/v3"
assert kwargs["api_key"] == "ark-key"
def test_ollama_resolver_uses_native_api_base() -> None: def test_ollama_resolver_uses_native_api_base() -> None:
model, kwargs = to_litellm( model, kwargs = to_litellm(
{ {

View file

@ -9,7 +9,10 @@ function baseUrlHint(provider: string) {
return "For local servers, use host.docker.internal instead of localhost."; return "For local servers, use host.docker.internal instead of localhost.";
} }
if (provider === "openai_compatible") { if (provider === "openai_compatible") {
return "Enter the full endpoint URL."; return "Enter the full endpoint URL. This provider expects a /v1-compatible endpoint.";
}
if (provider === "openai_compatible_raw") {
return "Enter the exact chat-completions API base URL. SurfSense will not append /v1.";
} }
if (provider === "openai" || provider === "anthropic" || provider === "openrouter") { if (provider === "openai" || provider === "anthropic" || provider === "openrouter") {
return "Override only if you route through a proxy or gateway."; return "Override only if you route through a proxy or gateway.";

View file

@ -10,6 +10,7 @@ export const PROVIDER_ORDER = [
"ollama_chat", "ollama_chat",
"lm_studio", "lm_studio",
"openai_compatible", "openai_compatible",
"openai_compatible_raw",
]; ];
export const PROVIDER_DISPLAY: Record< export const PROVIDER_DISPLAY: Record<
@ -37,6 +38,11 @@ export const PROVIDER_DISPLAY: Record<
subtitle: "OpenAI-compatible endpoint", subtitle: "OpenAI-compatible endpoint",
iconKey: "custom", iconKey: "custom",
}, },
openai_compatible_raw: {
name: "OpenAI-Compatible Raw",
subtitle: "Use the exact base URL, no /v1 is appended",
iconKey: "custom",
},
openrouter: { openrouter: {
name: "OpenRouter", name: "OpenRouter",
subtitle: "OpenRouter", subtitle: "OpenRouter",