{"record":{"id":"aaae8cd22eb0dedf","repo":"BerriAI/litellm","slug":"api-base-is-none-please-set-azure-ai-api-base-or","errorCode":null,"errorMessage":"api_base is None. Please set AZURE_AI_API_BASE or dynamically via `api_base` param, to make the request.","messagePattern":"api_base is None\\. Please set AZURE_AI_API_BASE or dynamically via `api_base` param, to make the request\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/embed/handler.py","lineNumber":102,"sourceCode":"            stream=False,\n            _response_headers=embedding_headers,\n        )\n        return returned_response\n\n    def image_embedding(\n        self,\n        model: str,\n        data: ImageEmbeddingRequest,\n        timeout: float,\n        logging_obj,\n        model_response: EmbeddingResponse,\n        optional_params: dict,\n        api_key: str | None,\n        api_base: str | None,\n        client: HTTPHandler | AsyncHTTPHandler | None = None,\n    ):\n        if api_base is None:\n            raise ValueError(\n                \"api_base is None. Please set AZURE_AI_API_BASE or dynamically via `api_base` param, to make the request.\"\n            )\n        if api_key is None:\n            raise ValueError(\n                \"api_key is None. Please set AZURE_AI_API_KEY or dynamically via `api_key` param, to make the request.\"\n            )\n\n        if client is None or not isinstance(client, HTTPHandler):\n            client = HTTPHandler(timeout=timeout, concurrent_limit=1)\n\n        url: Final = f\"{api_base}/images/embeddings\"\n\n        response: Final = client.post(\n            url=url,\n            json=data,\n            headers={\"Authorization\": f\"Bearer {api_key}\"},\n        )\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/embed/handler.py#L84-L120","documentation":"The Azure AI image-embeddings handler POSTs to {api_base}/images/embeddings. Without api_base the URL cannot be built, so it raises ValueError pointing you to the AZURE_AI_API_BASE env var or the api_base parameter. Raised in the sync and async embedding paths before any HTTP traffic.","triggerScenarios":"litellm.embedding() on an azure_ai image-embedding model without api_base on the call and without AZURE_AI_API_BASE in the environment; config built for text embeddings (which may resolve a default) reused for the image route.","commonSituations":"Adding image embedding support to an existing text-embedding service and forgetting the Foundry endpoint; env var not propagated to k8s pod; mixing up AZURE_API_BASE vs AZURE_AI_API_BASE.","solutions":["Pass api_base (your Foundry project endpoint, e.g. https://<resource>.services.ai.azure.com) to the embedding call.","Or export AZURE_AI_API_BASE in the runtime environment.","In proxy config, set api_base in the image-embedding deployment's litellm_params.","Confirm the resource actually exposes /images/embeddings (a Cohlete image-embedding deployment) with curl before retrying."],"exampleFix":"# before\nlitellm.embedding(model='azure_ai/<image-embed-model>', input=[img_b64])\n\n# after\nlitellm.embedding(\n    model='azure_ai/<image-embed-model>',\n    input=[img_b64],\n    api_base='https://myres.services.ai.azure.com',\n    api_key=AZURE_AI_KEY,\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef image_embed_base() -> str:\n    base = os.getenv('AZURE_AI_API_BASE')\n    if not base:\n        raise RuntimeError('image embeddings need AZURE_AI_API_BASE or api_base param')\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    litellm.embedding(model='azure_ai/img', input=imgs, api_base=image_embed_base())\nexcept ValueError as e:\n    if 'AZURE_AI_API_BASE' in str(e):\n        raise ConfigurationError(str(e)) from e\n    raise","preventionTips":["Extend your startup config check to image-embedding routes, not just chat.","Keep the Foundry endpoint in a shared secret/config store so all Azure AI calls agree.","Unit-test config resolution so missing env fails in CI, not in production."],"tags":["azure","embeddings","image","configuration","api-base"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}