{"record":{"id":"fe1efc8d77a0309e","repo":"odysseus-dev/odysseus","slug":"openai-endpoint-has-no-api-key-stored-edit-it-in","errorCode":null,"errorMessage":"OpenAI endpoint has no api_key stored — edit it in Endpoints settings.","messagePattern":"OpenAI endpoint has no api_key stored — edit it in Endpoints settings\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/gallery/gallery_routes.py","lineNumber":1316,"sourceCode":"                    raise HTTPException(403, \"Choose a registered image endpoint\")\n                base = ep.base_url.rstrip(\"/\")\n                api_key = ep.api_key\n            finally:\n                db.close()\n\n        if not base.endswith(\"/v1\"):\n            base += \"/v1\"\n\n        is_openai = _is_openai_api_base(base)\n\n        if is_openai:\n            # OpenAI path: /v1/images/edits with gpt-image-1.\n            # Mask convention differs from Stable Diffusion:\n            #   SD:     white pixels = regenerate, black = keep\n            #   OpenAI: transparent alpha = regenerate, opaque = keep\n            # So we convert the incoming PNG mask into an alpha-channel PNG.\n            if not api_key:\n                raise HTTPException(400, \"OpenAI endpoint has no api_key stored — edit it in Endpoints settings.\")\n            import base64, io\n            try:\n                from PIL import Image\n            except ImportError:\n                raise HTTPException(500, \"Pillow not installed on server\")\n\n            try:\n                img_bytes = base64.b64decode(body[\"image\"])\n                mask_bytes = base64.b64decode(body[\"mask\"])\n                source_png = Image.open(io.BytesIO(img_bytes)).convert(\"RGBA\")\n                mask_png = Image.open(io.BytesIO(mask_bytes)).convert(\"L\")  # luminance\n                # Build OpenAI mask: RGBA where alpha=255 means keep, 0 means regenerate.\n                # SD mask: white (255) = regenerate → alpha 0.  Black (0) = keep → alpha 255.\n                # RGB must be white for keep areas; start from fully-white opaque and\n                # overwrite alpha so visual contents match the expected semantic.\n                alpha = mask_png.point(lambda p: 255 - p)\n                oa_mask = Image.new(\"RGBA\", source_png.size, (255, 255, 255, 255))\n                oa_mask.putalpha(alpha)","sourceCodeStart":1298,"sourceCodeEnd":1334,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/gallery/gallery_routes.py#L1298-L1334","documentation":"Error \"OpenAI endpoint has no api_key stored — edit it in Endpoints settings.\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Edit the endpoint in Endpoints settings and add its API key.","Create a new endpoint entry with a valid OpenAI API key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}