Repository navigation
BYOK: users bring their own model and Tavily keys; free allowance on the platform key; Settings page - #88
Merged
Conversation
…'s provider; rejected keys are reported
…y a 403 config error blames the key
… and shows on the inbox status
…0 questions/day, 20 invoice reads)
…a key runs out; BYOK docs
…over the allowance; documents questions count; review fixes
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
BYOK (SPEC-BYOK, plan docs/superpowers/plans/2026-10-16-byok.md). A user can paste their own key for OpenAI, Anthropic, Gemini, Groq or OpenRouter, plus Tavily for web search. From then on Ask Lumen, invoice reading and email parsing use that key, with a model Lumen picks from a curated list. Users without a key get a free allowance on the platform key, then a prompt to add their own.
What changed
llm/registry.yamlbyok:catalogue (models per provider and role); OpenAI + Anthropic adapters (drop temperature,max_completion_tokens, thinking off). Env overrides areLUMEN_OPENAI_BASE_URL/LUMEN_ANTHROPIC_BASE_URL.user_keystable (created bycreate_all). Keys are encrypted with a dedicatedKEYS_ENCRYPTION_KEYthat has no SECRET_KEY fallback: without it, saving returns 503.llm/keys.py: a contextvar holding the request's user, set byrequire_auth, FastAPI agent/documents ask and the poller. With a user key for a role the chain is only the user's providers, never the platform's. A role no user key covers (e.g. vision for Groq-only) uses the platform chain. With no user in context, behaviour is byte-identical, so eval cassettes still replay.key_rejected("Your OpenAI key was rejected. Update it in Settings."), setsuser_keys.last_error, and is never retried on the platform key. A stored key that can't be decrypted fails without sending anything. Keys are masked in every log, error and response, including the shared 422 handler, which no longer logs Pydanticinput./api/keys: GET (last 4 only), PUT (validated with one cheap call, 5/min), POST test, DELETE.PLATFORM_QUESTIONS_PER_DAY=20for every keyless user, counted on /chat, /api/agent/ask and /api/documents/ask.PLATFORM_INVOICE_READS=20lifetime, counted from review_items. Over either limit: 402needs_key./settingspage (bare-bones): one row per provider with Add/Replace, Test, Remove and Advanced model picks; chat and inbox prompts link to Settings.Rulings made during the build
LUMEN_*_BASE_URL: Claude Code and the OpenAI SDK exportANTHROPIC_BASE_URL/OPENAI_BASE_URL, which would redirect user keys.KEYS_ENCRYPTION_KEY.Tests
tsc --noEmitclean, lint clean,next buildOK (/settingsbuilt).Not tested
thinking: disabled) are unverified.Before releasing to main (owner)
KEYS_ENCRYPTION_KEY(random 32+ chars) on Renderlumen-api-sg. render.yaml'sgenerateValueonly applies to new blueprint services. Without it, saving a key returns 503, and nothing else breaks.Deferred minors (25, all triaged "can wait" by the whole-branch review): e.g. the Advanced model pick only saves with Replace, failed non-invoice /extract reads aren't counted, and a rejected Tavily key keeps the tool offered.