{"record":{"id":"f0d96c6fd609208c","repo":"BerriAI/litellm","slug":"cometapi-key-or-cometapi-api-key-is-not-set","errorCode":null,"errorMessage":"COMETAPI_KEY or COMETAPI_API_KEY is not set","messagePattern":"COMETAPI_KEY or COMETAPI_API_KEY is not set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/cometapi/image_generation/transformation.py","lineNumber":97,"sourceCode":"        )\n\n        complete_url = complete_url.rstrip(\"/\")\n        complete_url = f\"{complete_url}/{self.IMAGE_GENERATION_ENDPOINT}\"\n        return complete_url\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        final_api_key: str | None = api_key or get_secret_str(\"COMETAPI_KEY\") or get_secret_str(\"COMETAPI_API_KEY\")\n        if not final_api_key:\n            raise ValueError(\"COMETAPI_KEY or COMETAPI_API_KEY is not set\")\n\n        headers[\"Authorization\"] = f\"Bearer {final_api_key}\"\n        headers[\"Content-Type\"] = \"application/json\"\n        return headers\n\n    def transform_image_generation_request(\n        self,\n        model: str,\n        prompt: str,\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,\n    ) -> dict:\n        \"\"\"\n        Transform the image generation request to the CometAPI image generation request body\n\n        https://api.cometapi.com/v1/images/generations\n        \"\"\"","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/cometapi/image_generation/transformation.py#L79-L115","documentation":"Credential guard in the CometAPI image-generation config: neither an explicit api_key nor the COMETAPI_KEY/COMETAPI_API_KEY secrets resolved, so the Authorization header cannot be built and the request is rejected before sending.","triggerScenarios":"Thrown at litellm/llms/cometapi/image_generation/transformation.py:97 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the COMETAPI_KEY environment variable before making the call, e.g. export COMETAPI_KEY=<your-key>.","Alternatively pass the credential directly via the api_key parameter in the litellm call.","COMETAPI_API_KEY is also accepted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}