Callers (e.g. siwen's key1/key2 dual-identity 杳眇 文官 pipeline) can
now pin a per-request LLM credential via the X-LLM-Key header on
/api/ask without bypassing the endpoint and losing RAG / file_back /
job_lock. get_client(api_key=) returns a fresh un-cached client;
chat / chat_with_context / query / query_with_search / _op_ask all
gain api_key forwarding; kb_ask op schema marks api_key writeOnly.
Security: header-only (body scanned iteratively for api_key-like
fields and rejected with 400); strong-auth gate when
LLMBASE_API_SECRET is set (cookie auth insufficient); key redacted
from error logs and final-retry exceptions; promote-judge uses
module singleton (insulated from per-query keys).
Hardening: Authorization parse now requires literal 'Bearer ' scheme
(previous .replace('Bearer ','') silently accepted raw secrets — HIGH
auth-bypass caught by Codex). Breaking change for any caller that
sent the naked secret; canonical form has always been the contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>