BerriAI/litellm · error · ValueError

API base is required for Topaz image variations

Error message

API base is required for Topaz image variations

What it means

Topaz image variations require an explicit api_base; provider_config.get_api_base() returned None at litellm/images/main.py:680 and litellm raises ValueError rather than assuming the Topaz endpoint.

Source

Thrown at litellm/images/main.py:680

            raise ValueError("API base is required for OpenAI image variations")

        response = openai_image_variations.image_variations(
            model_response=model_response,
            api_key=api_key,
            api_base=api_base,
            model=model,
            image=image,
            timeout=litellm_params.get("timeout", None),
            custom_llm_provider=custom_llm_provider,
            logging_obj=litellm_logging_obj,
            optional_params={},
            litellm_params=litellm_params,
        )
    elif image_variation_provider == LITELLM_IMAGE_VARIATION_PROVIDERS.TOPAZ:
        if api_key is None:
            raise ValueError("API key is required for Topaz image variations")
        if api_base is None:
            raise ValueError("API base is required for Topaz image variations")

        response = base_llm_aiohttp_handler.image_variations(
            model_response=model_response,
            api_key=api_key,
            api_base=api_base,
            model=model,
            image=image,
            timeout=litellm_params.get("timeout", None) or DEFAULT_REQUEST_TIMEOUT,
            custom_llm_provider=custom_llm_provider,
            logging_obj=litellm_logging_obj,
            optional_params={},
            litellm_params=litellm_params,
            client=client,
        )

    # return the response
    if response is None:
        raise ValueError(

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass api_base explicitly: api_base='https://api.topazlabs.com'
  2. Or configure the base URL in the environment/litellm.api_base so get_api_base resolves it
  3. For self-hosted Topaz-compatible endpoints, point api_base at your gateway

Example fix

# before
litellm.image_variations(model="topaz/topaz-image-alter-v1", image=img, api_key=key)

# after
litellm.image_variations(model="topaz/topaz-image-alter-v1", image=img, api_key=key, api_base="https://api.topazlabs.com")
Defensive patterns

Strategy: validation

Validate before calling

TOPAZ_DEFAULT_BASE = "https://api.topazlabs.com"

def topaz_base(explicit: str | None = None) -> str:
    return explicit or TOPAZ_DEFAULT_BASE

Try / catch

try:
    r = litellm.image_variations(model=m, image=img, api_key=k)
except ValueError as e:
    if "API base is required for Topaz" in str(e):
        return litellm.image_variations(model=m, image=img, api_key=k, api_base="https://api.topazlabs.com")
    raise

Prevention

When it happens

Trigger: Calling litellm.image_variations(model='topaz/...', ...) with a key but no api_base argument and no resolvable environment base URL for Topaz.

Common situations: Developer assumes the default https://api.topazlabs.com is applied automatically; on-prem gateway users forgetting to configure the base.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/f86850922a563382. Report an issue: GitHub.