feat(llm): Support per-request SSO JWT passthrough to LiteLLM proxy for JWT → Virtual Key
Summary
When using Onyx with a LiteLLM proxy that has JWT → Virtual Key authentication enabled, Onyx currently has no way to forward the end-user's SSO-obtained JWT as the Authorization: Bearer header on each LLM request. This makes it impossible to leverage LiteLLM's teams configuration and user configurations in Onyx.
Motivation / Use Case
Many organizations deploy a LiteLLM proxy in front of their LLM providers to enforce per-user budgets, rate limits, and cost tracking. LiteLLM supports a JWT → Virtual Key feature where:
- Each request arrives at LiteLLM with
Authorization: Bearer - LiteLLM validates the JWT and extracts a configured claim (e.g.
emailandteam_alias) - It looks up a mapped virtual key in
LiteLLM_JWTKeyMapping - Per-user / per-team budgets, rate limits, and spend are applied
Onyx is a natural fit as the frontend for non-technical users in such a setup — it handles SSO, it manages chat sessions, and it already obtains a valid JWT during user authentication. However, Onyx currently forwards only a static admin-level API key to LiteLLM, making all requests indistinguishable from each other at the proxy level.
Current Behavior
• Onyx uses a single, static API key configured at the admin level to authenticate against LiteLLM.
• All user requests to LiteLLM share the same Authorization header.
• Per-user virtual key resolution at LiteLLM is not possible.
Desired Behavior
Onyx should support an option to forward the authenticated user's SSO JWT (obtained during login) as the Authorization: Bearer header on per-request calls to a configured LiteLLM proxy.
Proposed flow:
User logs into Onyx via SSO
│
▼
Onyx stores the user's JWT (scoped to their session)
│
▼
User sends a chat message → Onyx makes LLM call
│
▼
Onyx forwards: Authorization: Bearer <user_jwt> ──► LiteLLM Proxy
│
▼
JWT validated → Virtual Key resolved
│
▼
Per-user spend tracked ✅
What This Is NOT (Important Distinction)
This request is different from the existing SEND_USER_METADATA_TO_LLM_PROVIDER feature and related open issues:
SEND_USER_METADATA_TO_LLM_PROVIDER** (PR #6564)**
• How identity is sent: user field in request body
• Triggers JWT→VKey?: ❌ No
Issue #10461 / PR #10499 / PR #10629
• How identity is sent: user
via extra_body or allowed_openai_params
• Triggers JWT→VKey?: ❌ No
This request
• How identity is sent: Authorization: Bearer header
• Triggers JWT→VKey?: ✅ Yes
The above PRs are still valuable for observability and LiteLLM's customer tracking feature, but they do not satisfy this use case.
Proposed Implementation Notes
• This feature could be gated behind a new environment variable, e.g. LITELLM_PROXY_JWT_PASSTHROUGH=true, to avoid breaking existing deployments.
• When enabled, Onyx should retrieve the user's current SSO JWT from the session and inject it into the Authorization header for LLM calls routed to the configured LiteLLM proxy.
• Care should be taken around JWT expiry — Onyx may need to refresh the token before forwarding if it is close to expiration.
• This should only apply when the target provider is a LiteLLM proxy (not direct provider calls).
Related Issues & PRs
• PR #6564 — SEND_USER_METADATA_TO_LLM_PROVIDER (merged) — forwards user identity in body, not header
• Issue #10461 — user and chat_session_id dropped for custom OpenAI-compatible providers (open bug)
• PR #10499 — Fix via extra_body (open)
• PR #10629 — Fix via allowed_openai_params (open)
• PR #2316 — Static access token passthrough for LiteLLM (merged)
Additional Context
Originally raised in the Onyx community Slack (#support channel). I am planning to deploy Onyx as a frontend for non-technical users over a LiteLLM proxy and wants to avoid issuing a shared Onyx API key, instead relying on per-user JWT mapping for cost attribution, LiteLLM's internal RBAC rules (organization, team, user rules)
Source: onyx-dot-app/onyx