{"record":{"id":"308bf97137f25a18","repo":"BerriAI/litellm","slug":"aiml-api-key-or-aimlapi-key-is-not-set","errorCode":null,"errorMessage":"AIML_API_KEY or AIMLAPI_KEY is not set","messagePattern":"AIML_API_KEY or AIMLAPI_KEY is not set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/aiml/image_generation/transformation.py","lineNumber":134,"sourceCode":"        complete_url = complete_url.removesuffix(\"/v1\")\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: Final[str | None] = (\n            api_key or get_secret_str(\"AIML_API_KEY\") or get_secret_str(\"AIMLAPI_KEY\")  # Alternative name\n        )\n        if not final_api_key:\n            raise ValueError(\"AIML_API_KEY or AIMLAPI_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 AI/ML image generation request body\n\n        https://api.aimlapi.com/v1/images/generations\n        \"\"\"","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/aiml/image_generation/transformation.py#L116-L152","documentation":"Error \"AIML_API_KEY or AIMLAPI_KEY is not set\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/aiml/image_generation/transformation.py:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set AIML_API_KEY or AIMLAPI_KEY in the environment."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}