From 215400cde7d334b8314a97bb2ac82dec8b8b798d Mon Sep 17 00:00:00 2001 From: Nathan Schneider Date: Mon, 19 Oct 2026 08:24:29 -0600 Subject: [PATCH] image gen: inject IC_API_KEY via env mapping; add SYSTEM_IMAGE_KEY fallback (system account) so unseeded members never fail --- librechat.yaml | 8 ++++++-- mcp/image_server.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/librechat.yaml b/librechat.yaml index 3f0eddc..3c18ef1 100644 --- a/librechat.yaml +++ b/librechat.yaml @@ -1,7 +1,8 @@ version: 1.3.17 -# Inference Co-op gateway — PER-USER keys: each member pastes their own -# dashboard key once (apiKey: user_provided). Usage bills to that member's +# Inference Co-op gateway — per-member keys. Each member's own dashboard +# key auto-loads at login (seeded into LibreChat's user-key store by +# /app/data/sync-keys.js from the portal). Usage bills to the member's # own LiteLLM team/budget. endpoints: custom: @@ -183,3 +184,6 @@ mcpServers: title: "Inference Co-op API key" description: "Auto-loaded from your membership — no action needed." sensitive: true + env: + IC_API_KEY: "{{IC_API_KEY}}" + SYSTEM_IMAGE_KEY: "${SYSTEM_IMAGE_KEY}" diff --git a/mcp/image_server.py b/mcp/image_server.py index 2adea7c..c87f97b 100644 --- a/mcp/image_server.py +++ b/mcp/image_server.py @@ -38,9 +38,14 @@ def log(msg): def tool_generate_image(args): # Seamless: use the member's own key if LibreChat injected one; otherwise - # fall back to a keyless request so members who never saved a key can - # still generate images (the gateway bills their shared co-op allowance). - key = (os.environ.get("IC_API_KEY") or "").strip() + # fall back to the co-op's SYSTEM key (so a member who has never been + # seeded — e.g. right after first login — still generates an image, + # billed to the system account). Only if both are absent send keyless. + key = ( + os.environ.get("IC_API_KEY") + or os.environ.get("SYSTEM_IMAGE_KEY") + or "" + ).strip() auth_header = {"Authorization": f"Bearer {key}"} if key else {} prompt = str(args.get("prompt") or "").strip()