feat(settings): per-organization provider API key management - #2
Merged
Merged
Conversation
Adds an encrypted-at-rest credential store (provider_credentials table) so each organization can configure its own LLM/embedding/reranking/ vector-index provider keys from a new Settings page, instead of relying solely on platform-wide env vars. Org-configured keys take precedence over the env-var default everywhere a provider is constructed (backend LLM Gateway, worker embedding/index/reranking factories); orgs that haven't configured anything fall back to existing behavior unchanged. Motivated by the earlier embeddings-not-working incident on Railway, where OPENAI_API_KEY was only configurable via a platform-wide env var with no per-org override and no UI path to fix it. Also includes a pending fix from earlier this session: worker/Dockerfile now pins Celery's --concurrency=2 (previously defaulted to the host's visible CPU count, 48, causing repeated OOM SIGKILLs on Railway). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
provider_credentialstable so each organization can configure its own LLM (openai/anthropic/gemini/groq/openrouter), embedding/reranking (voyage/jina/cohere), and vector-index (pinecone) provider keys from a new Settings page, instead of relying solely on platform-wide env vars.OPENAI_API_KEYwas only configurable via a platform-wide env var with no per-org override and no UI path to fix it.worker/Dockerfilenow pins Celery's--concurrency=2(it previously defaulted to the host's visible CPU count — 48 on Railway — causing repeated OOM SIGKILLs).Security note
CREDENTIAL_ENCRYPTION_KEYships with an insecure hardcoded dev default (documented inline, same pattern asjwt_secret_key). Before this is used in production, set a real value (Fernet.generate_key()) on both the Railway backend and worker services — identically on both, since each decrypts independently.Test plan
pytest— 165 passed (7 new tests for the new endpoints/service), migration verified upgrade→downgrade→upgrade,ruff/mypycleanpytest— 151 passed, 9 skipped (unset cloud keys, expected),ruffcleantsc --noEmitand lint clean on all new files🤖 Generated with Claude Code