From 95fa3fbe30198917bdcce4000881530b9adab079 Mon Sep 17 00:00:00 2001 From: Michael Han <107991372+shimmyshimmer@users.noreply.github.com> Date: Sat, 18 Jul 2026 22:47:00 -0700 Subject: [PATCH] Allow API key for Ollama connections (#7173) The Connections form hid the API key field for the Ollama preset, which blocked Ollama cloud (it requires a key). Show the optional field for Ollama; the backend already sends Authorization: Bearer when a key is set and omits the header when empty, so local keyless servers are unaffected. Fixes #7163 --- studio/backend/core/inference/providers.py | 5 +++-- studio/frontend/src/features/chat/chat-providers-dialog.tsx | 4 ++-- studio/frontend/src/features/chat/external-providers.ts | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.py index 5b72373c03..d3bffc2f3d 100644 --- a/studio/backend/core/inference/providers.py +++ b/studio/backend/core/inference/providers.py @@ -276,8 +276,9 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = { "auth_header": "Authorization", "auth_prefix": "Bearer ", "notes": ( - "Local Ollama server. OpenAI-compatible /v1/chat/completions; " - "no API key. Surfaced via CUSTOM_PROVIDER_PRESETS in the frontend." + "Ollama server (local or cloud). OpenAI-compatible " + "/v1/chat/completions; API key optional (required by Ollama " + "cloud). Surfaced via CUSTOM_PROVIDER_PRESETS in the frontend." ), "hidden": True, }, diff --git a/studio/frontend/src/features/chat/chat-providers-dialog.tsx b/studio/frontend/src/features/chat/chat-providers-dialog.tsx index 95e5cfbd79..e39955e576 100644 --- a/studio/frontend/src/features/chat/chat-providers-dialog.tsx +++ b/studio/frontend/src/features/chat/chat-providers-dialog.tsx @@ -244,8 +244,8 @@ export function ChatProvidersSettings({ (s) => s.setConnectionsEnabled, ); const isCustomProvider = isCustomProviderType(providerType); - // Local presets (Ollama, llama.cpp) never use API keys — hide the field. - // vLLM may optionally use a bearer token on secured deployments. + // llama.cpp hides the key field. Ollama and vLLM show an optional key: + // Ollama cloud and secured vLLM need one; local servers leave it empty. const showApiKeyField = !customPresetSkipsApiKeyField(providerType); const showReasoningToggle = supportsProviderReasoningToggle(providerType); diff --git a/studio/frontend/src/features/chat/external-providers.ts b/studio/frontend/src/features/chat/external-providers.ts index bc718abbba..eb9e4656b0 100644 --- a/studio/frontend/src/features/chat/external-providers.ts +++ b/studio/frontend/src/features/chat/external-providers.ts @@ -184,11 +184,12 @@ export function supportsRemoteModelCatalog( ); } -/** Presets that skip the API-key field (local servers with no auth by default). */ +/** Presets that hide the API-key field. Ollama is not skipped: Ollama cloud + * requires a key; local servers leave the optional field empty. */ export function customPresetSkipsApiKeyField( providerType: string | null | undefined, ): boolean { - return providerType === "ollama" || providerType === "llama_cpp"; + return providerType === "llama_cpp"; } /** Catalog load plus optional manual model IDs. */