{"record":{"id":"40cb4096789032d0","repo":"BerriAI/litellm","slug":"api-base-is-required-for-azure-ai-studio-please-s-40cb40","errorCode":null,"errorMessage":"api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`","messagePattern":"api_base is required for Azure AI Studio\\. Please set the api_base parameter\\. Passed `api_base=(.+?)`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/image_edit/transformation.py","lineNumber":93,"sourceCode":"    ) -> str:\n        \"\"\"\n        Constructs a complete URL for the API request.\n\n        Args:\n        - api_base: Base URL, e.g.,\n            \"https://litellm8397336933.openai.azure.com\"\n            OR\n            \"https://litellm8397336933.openai.azure.com/openai/deployments/<deployment_name>/images/edits?api-version=2024-05-01-preview\"\n        - model: Model name (deployment name).\n        - litellm_params: Additional query parameters, including \"api_version\".\n\n        Returns:\n        - A complete URL string, e.g.,\n        \"https://litellm8397336933.openai.azure.com/openai/deployments/<deployment_name>/images/edits?api-version=2024-05-01-preview\"\n        \"\"\"\n        api_base = api_base or litellm.api_base or get_secret_str(\"AZURE_API_BASE\")\n        if api_base is None:\n            raise ValueError(\n                f\"api_base is required for Azure AI Studio. Please set the api_base parameter. Passed `api_base={api_base}`\"\n            )\n        original_url: Final = httpx.URL(api_base)\n\n        # Resolve api_version: litellm_params > litellm.api_version > AZURE_API_VERSION env > default.\n        # Mirrors the fallback chain used by the Azure chat path in common_utils.py,\n        # so callers that set a global / env api_version don't get an unversioned URL.\n        api_version: Final = (\n            cast(str | None, litellm_params.get(\"api_version\"))\n            or litellm.api_version\n            or get_secret_str(\"AZURE_API_VERSION\")\n            or litellm.AZURE_DEFAULT_API_VERSION\n        )\n\n        # Create a new dictionary with existing params\n        query_params: Final = dict(original_url.params)\n\n        # Add api_version if needed","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/image_edit/transformation.py#L75-L111","documentation":"The Azure image-edit transformation builds the full request URL from an api_base that is resolved through the chain: api_base argument -> litellm.api_base global -> AZURE_API_BASE environment variable. If all three are empty this ValueError fires, because Azure image edits require the resource endpoint (e.g. https://<resource>.openai.azure.com) to construct the /openai/deployments/<deployment>/images/edits URL. It is raised before any HTTP request.","triggerScenarios":"Calling azure image edit without api_base while litellm.api_base is unset and AZURE_API_BASE is not exported; passing model='azure/<deployment>' believing the deployment name alone locates the resource.","commonSituations":"Configs that set AZURE_API_KEY and AZURE_API_VERSION but never AZURE_API_BASE; migrating from chat calls (which resolve the base elsewhere) to image edits; environment-specific .env files missing the base URL key.","solutions":["Pass api_base='https://<your-resource>.openai.azure.com' explicitly to the image edit call.","Or export AZURE_API_BASE in the environment.","Or set litellm.api_base globally at startup.","Note api_version may also be needed; it resolves from litellm_params, litellm.api_version, AZURE_API_VERSION, then a default."],"exampleFix":"# before\nresp = litellm.azure_image_edit(model='azure/my-deployment', image_data=img, prompt='remove background')\n\n# after\nresp = litellm.azure_image_edit(\n    model='azure/my-deployment',\n    image_data=img,\n    prompt='remove background',\n    api_base='https://myresource.openai.azure.com',\n    api_key=os.environ['AZURE_API_KEY'],\n)","handlingStrategy":"validation","validationCode":"import os, litellm\n\ndef resolve_azure_api_base(api_base: str | None) -> str:\n    base = api_base or litellm.api_base or os.environ.get('AZURE_API_BASE')\n    if not base:\n        raise ValueError('Azure image edit requires api_base (arg, litellm.api_base, or AZURE_API_BASE)')\n    return base","typeGuard":null,"tryCatchPattern":"try:\n        resp = litellm.azure_image_edit(..., api_base=api_base)\n    except ValueError as e:\n        if 'api_base is required' in str(e):\n            raise ValueError('set AZURE_API_BASE or pass api_base for image edits') from e\n        raise","preventionTips":["Always configure AZURE_API_BASE alongside AZURE_API_KEY.","Treat the three-part Azure config (base, key, version) as one unit in deployment templates."],"tags":["azure","openai","image-edit","api-base","configuration","url-construction"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}