Skip to content

Allow API key for Ollama connections - #7173

Merged
shimmyshimmer merged 1 commit into
mainfrom
fix/ollama-connection-api-key
Jul 19, 2026
Merged

shimmyshimmer merged 1 commit into
mainfrom
fix/ollama-connection-api-key

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Fixes #7163

Problem

The Connections form (Settings > Connections) hid the API key field for the Ollama preset. customPresetSkipsApiKeyField in external-providers.ts returned true for both ollama and llama_cpp, so there was no way to enter a key. Ollama cloud requires one, so cloud endpoints could only be used through a Custom connection workaround.

Fix

Everything downstream was already key capable: the provider registry defines Authorization: Bearer auth for ollama, and model listing, connection tests, and chat requests all forward a stored key. The only blocker was the hidden input.

  • external-providers.ts: remove ollama from customPresetSkipsApiKeyField, only llama_cpp still hides the field
  • chat-providers-dialog.tsx: update the stale comment at the showApiKeyField computation
  • providers.py: update the ollama registry note from "no API key" to "API key optional (required by Ollama cloud)"

Since Ollama is a custom provider type, the existing form logic already labels the field as optional, stores the key locally per connection, and removes a stored key when the field is saved empty.

Behavior

  • Ollama cloud: set Base URL to https://ollama.com/v1 and paste a key, requests send Authorization: Bearer <key>
  • Local Ollama: leave the field empty, no auth header is sent (avoids the httpx "Illegal header value" failure on an empty Bearer), so existing setups are unaffected

Testing

  • tsc -b passes
  • Verified against the backend client: an ollama provider with a key produces Authorization: Bearer <key>; with an empty key no auth header is present
  • Rebuilt the frontend and confirmed the Connections form shows "API key (optional)" for Ollama

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Ollama provider configuration to support an optional API key, which is required for Ollama cloud deployments. The frontend has been updated to display the API key field for Ollama (making it optional for local servers and required for cloud), whereas previously it was hidden. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@oobabooga

Copy link
Copy Markdown
Member

@shimmyshimmer LGTM to merge as-is.

@shimmyshimmer
shimmyshimmer merged commit 95fa3fb into main Jul 19, 2026
50 of 54 checks passed
@shimmyshimmer
shimmyshimmer deleted the fix/ollama-connection-api-key branch July 19, 2026 05:47
VectorCipher pushed a commit to VectorCipher/unsloth that referenced this pull request Jul 20, 2026
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 unslothai#7163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Ollama in "Connections" cannot accept an API Key

2 participants