BerriAI/litellm · error · ValueError
COMETAPI_KEY or COMETAPI_API_KEY is not set
Error message
COMETAPI_KEY or COMETAPI_API_KEY is not set
What it means
Error "COMETAPI_KEY or COMETAPI_API_KEY is not set" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/cometapi/image_generation/transformation.py:97
)
complete_url = complete_url.rstrip("/")
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: str | None = api_key or get_secret_str("COMETAPI_KEY") or get_secret_str("COMETAPI_API_KEY")
if not final_api_key:
raise ValueError("COMETAPI_KEY or COMETAPI_API_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 CometAPI image generation request body
https://api.cometapi.com/v1/images/generations
"""View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set COMETAPI_KEY or COMETAPI_API_KEY in the environment.
When it happens
Trigger: Thrown at litellm/llms/cometapi/image_generation/transformation.py:97 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/f0d96c6fd609208c.
Report an issue: GitHub.