Skip to content

fix: restore api keys tab and apply session key to pipeline default m…#504

Open
harz05 wants to merge 1 commit into
archi-physics:mainfrom
harz05:fix/api-keys-tab
Open

fix: restore api keys tab and apply session key to pipeline default m…#504
harz05 wants to merge 1 commit into
archi-physics:mainfrom
harz05:fix/api-keys-tab

Conversation

@harz05

@harz05 harz05 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #475

Problems

  1. The API Keys tab in chat Settings was hidden (<!-- commented out -->) due to a known bug where the session key was ignored.

  2. When a user saved a session API key but did NOT explicitly select a provider in the UI (i.e. used the pipeline default model), the session key was never looked up and the deployment admin key was always used instead, reverting any per-user override.

Fix

index.html — Uncommented the API Keys nav button and section. Updated the description to clarify keys live in the browser session only.

app.py — In get_chat_response_stream(), extended the session key lookup to also cover the no-provider-selected case: when no explicit provider comes in from the frontend, the code now reads the pipeline's active model from dynamic_config (or falls back to services.chat_app.default_provider), checks if the user has a session key for that provider, and injects it — so the BYOK key is used transparently even with the default pipeline model.

Tested

  • Set a fake session key (sk-fake999) → sent a message → got an auth error from OpenAI confirming the session key was injected
  • Cleared session key → chat worked normally with env key
  • API Keys tab visible and functional in Settings modal
Screenshot from 2026-03-06 02-38-35

@juanpablosalas juanpablosalas self-requested a review July 6, 2026 14:35

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For some reason the clear, button is not working. Even after I clear the fake API key and I see that is taking the ENV value, the chat logs fail with the previously entered key:

openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-fake999.. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key', 'param': None}, 'status': 401}``` 

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.

fix api keys tab in chat settings

2 participants