Skip to content

fix: allow API key input for Ollama/local proxy providers#695

Open
shivangtanwar wants to merge 1 commit intosrbhr:mainfrom
shivangtanwar:fix/609-enable-api-key-for-local-proxies
Open

fix: allow API key input for Ollama/local proxy providers#695
shivangtanwar wants to merge 1 commit intosrbhr:mainfrom
shivangtanwar:fix/609-enable-api-key-for-local-proxies

Conversation

@shivangtanwar
Copy link
Copy Markdown
Contributor

@shivangtanwar shivangtanwar commented Mar 3, 2026

Summary

  • The API key input was disabled for Ollama (disabled={!requiresApiKey}), preventing users with proxied local models (e.g. CLIProxyAPI) from entering an authentication token.
  • The save handler also unconditionally cleared api_key to '' for Ollama, discarding any key even if the user managed to enter one.
  • Now the API key field is always editable. The "(not required for Ollama)" hint stays visible so users know it's optional for standard Ollama setups.

Changes

  1. Removed disabled={!requiresApiKey} from the API key <Input> — field is always editable
  2. Unified handleSave logic — sends the key if provided, sends empty if no key exists, regardless of provider
  3. Unified handleTest logic — includes API key in test connection for all providers
  4. "Leave blank to keep existing key" hint now shows for all providers with a stored key

Test plan

  • Select Ollama provider — verify API key field is editable (was previously grayed out)
  • Enter an API key for Ollama with a custom base URL — verify it saves and persists
  • Test connection with Ollama + API key — verify key is sent in the test request
  • Select OpenAI without a key — verify validation still blocks saving
  • Save with a standard Ollama (no key) — verify it works as before

Closes #609


Summary by cubic

Enables API key input for Ollama and local proxy providers so authenticated local setups can save and test connections. Fulfills #609 by sending the key when provided while keeping Ollama key optional.

  • Bug Fixes
    • API key field is always editable; removed the disabled state.
    • Save logic sends a trimmed key; otherwise clears only if no stored key.
    • Test connection includes the key when provided; uses stored key if left blank.
    • “Leave blank to keep existing key” hint shows when a stored key exists.

Written for commit 3880b5e. Summary will update on new commits.

The API key field was disabled for Ollama via `disabled={!requiresApiKey}`,
preventing users with proxied local models that require authentication
from entering a key. The save handler also unconditionally cleared the
key for non-requiresKey providers.

Changes:
- Remove `disabled` prop from API key input so it's always editable
- Unify save logic to send the key if provided, regardless of provider
- Include API key in test connection requests for all providers
- Keep the "(not required)" hint for Ollama to indicate it's optional

Closes srbhr#609
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 3, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR removes the requiresApiKey conditional checks from the API key handling logic in the settings page. The changes are well-designed and improve flexibility:

  1. handleSave function - Now allows optional API keys for all providers (e.g., Ollama) instead of always clearing the key for providers that don't require one.

  2. handleTestConnection function - Allows testing with an API key for any provider, not just those that require it.

  3. Input field - Removes the disabled attribute, enabling users to optionally provide API keys for providers like Ollama.

Key Observations

  • No API breaking changes - The backend API already handles optional API keys correctly
  • Validation preserved - The required key validation at line 310 (if (requiresApiKey && !apiKey.trim() && !hasStoredApiKey)) is correctly kept in place
  • LiteLLM compatibility - Changes improve configuration flexibility for LiteLLM providers
  • No prompt flow issues - Changes don't affect prompt handling
Files Reviewed (1 file)
  • apps/frontend/app/(default)/settings/page.tsx - 0 issues

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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.

[Feature]: Support local proxied models

1 participant