{"record":{"id":"f86850922a563382","repo":"BerriAI/litellm","slug":"api-base-is-required-for-topaz-image-variations","errorCode":null,"errorMessage":"API base is required for Topaz image variations","messagePattern":"API base is required for Topaz image variations","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/images/main.py","lineNumber":680,"sourceCode":"            raise ValueError(\"API base is required for OpenAI image variations\")\n\n        response = openai_image_variations.image_variations(\n            model_response=model_response,\n            api_key=api_key,\n            api_base=api_base,\n            model=model,\n            image=image,\n            timeout=litellm_params.get(\"timeout\", None),\n            custom_llm_provider=custom_llm_provider,\n            logging_obj=litellm_logging_obj,\n            optional_params={},\n            litellm_params=litellm_params,\n        )\n    elif image_variation_provider == LITELLM_IMAGE_VARIATION_PROVIDERS.TOPAZ:\n        if api_key is None:\n            raise ValueError(\"API key is required for Topaz image variations\")\n        if api_base is None:\n            raise ValueError(\"API base is required for Topaz image variations\")\n\n        response = base_llm_aiohttp_handler.image_variations(\n            model_response=model_response,\n            api_key=api_key,\n            api_base=api_base,\n            model=model,\n            image=image,\n            timeout=litellm_params.get(\"timeout\", None) or DEFAULT_REQUEST_TIMEOUT,\n            custom_llm_provider=custom_llm_provider,\n            logging_obj=litellm_logging_obj,\n            optional_params={},\n            litellm_params=litellm_params,\n            client=client,\n        )\n\n    # return the response\n    if response is None:\n        raise ValueError(","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/images/main.py#L662-L698","documentation":"The Topaz branch resolves api_base via provider_config.get_api_base (explicit argument or litellm.api_base) and raises when it is None — unlike the key, no Topaz default URL is auto-applied on this path. The subsequent aiohttp handler would have nothing to POST the image to, so litellm aborts early.","triggerScenarios":"Calling image_variation with a topaz model and api_key set but no api_base and no litellm.api_base; assuming litellm knows Topaz's URL automatically; copying an OpenAI-variation call and only changing the model.","commonSituations":"First-time Topaz integrations following docs that show the key but not the base; proxy config with topaz model entries missing the api_base litellm_param.","solutions":["Pass api_base explicitly, e.g. api_base='https://www.topazlabs.com/api' (or your Topaz endpoint) in the call.","Or set litellm.api_base once if all Topaz traffic shares one endpoint.","Add api_base to the topaz model's litellm_params in Router/proxy config.","Wrap a small client function that always injects provider, key, and base so call sites cannot omit them."],"exampleFix":"# before\nresp = litellm.image_variation(model=\"topaz/upscayl\", image=img, api_key=key)\n# ValueError: API base is required for Topaz image variations\n\n# after\nresp = litellm.image_variation(model=\"topaz/upscayl\", image=img, api_key=key, api_base=\"https://www.topazlabs.com/api\")","handlingStrategy":"validation","validationCode":"TOPAZ_API_BASE = \"https://www.topazlabs.com/api\"\n\ndef topaz_variation(model, image, api_key):\n    return litellm.image_variation(\n        model=model, image=image, api_key=api_key, api_base=TOPAZ_API_BASE\n    )  # api_base never omitted","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_variation(model=\"topaz/upscayl\", image=img, api_key=key)\nexcept ValueError as e:\n    if \"API base is required for Topaz image variations\" in str(e):\n        resp = litellm.image_variation(model=\"topaz/upscayl\", image=img, api_key=key, api_base=\"https://www.topazlabs.com/api\")\n    else:\n        raise","preventionTips":["Keep provider, key, and base as one bundled config so no call site can pass a partial set.","Document that Topaz variation has no auto-default URL in litellm.","Add api_base to topaz model litellm_params in Router/proxy configs."],"tags":["litellm","image-variation","topaz","api-base","endpoint-url"],"backgroundTag":"missing-api-base-url","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}