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

+8 -3
View File
@@ -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()