BerriAI/litellm · error · ValueError
AIML_API_KEY or AIMLAPI_KEY is not set
Error message
AIML_API_KEY or AIMLAPI_KEY is not set
What it means
Error "AIML_API_KEY or AIMLAPI_KEY is not set" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/aiml/image_generation/transformation.py:134
complete_url = complete_url.removesuffix("/v1")
complete_url = f"{complete_url}/{self.IMAGE_GENERATION_ENDPOINT}"
return complete_url
def validate_environment(
self,
headers: dict,
model: str,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
api_key: str | None = None,
api_base: str | None = None,
) -> dict:
final_api_key: Final[str | None] = (
api_key or get_secret_str("AIML_API_KEY") or get_secret_str("AIMLAPI_KEY") # Alternative name
)
if not final_api_key:
raise ValueError("AIML_API_KEY or AIMLAPI_KEY is not set")
headers["Authorization"] = f"Bearer {final_api_key}"
headers["Content-Type"] = "application/json"
return headers
def transform_image_generation_request(
self,
model: str,
prompt: str,
optional_params: dict,
litellm_params: dict,
headers: dict,
) -> dict:
"""
Transform the image generation request to the AI/ML image generation request body
https://api.aimlapi.com/v1/images/generations
"""View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set AIML_API_KEY or AIMLAPI_KEY in the environment.
When it happens
Trigger: Thrown at litellm/llms/aiml/image_generation/transformation.py:134 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/308bf97137f25a18.
Report an issue: GitHub.