image gen: inject IC_API_KEY via env mapping; add SYSTEM_IMAGE_KEY fallback (system account) so unseeded members never fail

This commit is contained in:
Nathan Schneider committed 2026-10-19 08:24:29 -06:00
1 parent 17d735d9ad
commit 215400cde7
2 files changed
+14 -5

No files matched your search

+6 -2
View File
@@ -1,7 +1,8 @@
version: 1.3.17 version: 1.3.17
# Inference Co-op gateway — PER-USER keys: each member pastes their own # Inference Co-op gateway — per-member keys. Each member's own dashboard
# dashboard key once (apiKey: user_provided). Usage bills to that member's # 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. # own LiteLLM team/budget.
endpoints: endpoints:
custom: custom:
@@ -183,3 +184,6 @@ mcpServers:
title: "Inference Co-op API key" title: "Inference Co-op API key"
description: "Auto-loaded from your membership — no action needed." description: "Auto-loaded from your membership — no action needed."
sensitive: true sensitive: true
env:
IC_API_KEY: "{{IC_API_KEY}}"
SYSTEM_IMAGE_KEY: "${SYSTEM_IMAGE_KEY}"
+8 -3
View File
@@ -38,9 +38,14 @@ def log(msg):
def tool_generate_image(args): def tool_generate_image(args):
# Seamless: use the member's own key if LibreChat injected one; otherwise # 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 # fall back to the co-op's SYSTEM key (so a member who has never been
# still generate images (the gateway bills their shared co-op allowance). # seeded — e.g. right after first login — still generates an image,
key = (os.environ.get("IC_API_KEY") or "").strip() # 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 {} auth_header = {"Authorization": f"Bearer {key}"} if key else {}
prompt = str(args.get("prompt") or "").strip() prompt = str(args.get("prompt") or "").strip()