BerriAI/litellm · error · ValueError

api_key is None. Please set AZURE_AI_API_KEY or dynamically…

Error message

api_key is None. Please set AZURE_AI_API_KEY or dynamically via `api_key` param, to make the request.

What it means

Error "api_key is None. Please set AZURE_AI_API_KEY or dynamically via `api_key` param, to make the request." thrown in BerriAI/litellm.

Solutions

  1. Set AZURE_AI_API_KEY or pass api_key.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/embed/handler.py:106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/33faf6f4aad92f53. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure_ai/embed/handler.py:106

    def image_embedding(
        self,
        model: str,
        data: ImageEmbeddingRequest,
        timeout: float,
        logging_obj,
        model_response: EmbeddingResponse,
        optional_params: dict,
        api_key: str | None,
        api_base: str | None,
        client: HTTPHandler | AsyncHTTPHandler | None = None,
    ):
        if api_base is None:
            raise ValueError(
                "api_base is None. Please set AZURE_AI_API_BASE or dynamically via `api_base` param, to make the request."
            )
        if api_key is None:
            raise ValueError(
                "api_key is None. Please set AZURE_AI_API_KEY or dynamically via `api_key` param, to make the request."
            )

        if client is None or not isinstance(client, HTTPHandler):
            client = HTTPHandler(timeout=timeout, concurrent_limit=1)

        url: Final = f"{api_base}/images/embeddings"

        response: Final = client.post(
            url=url,
            json=data,
            headers={"Authorization": f"Bearer {api_key}"},
        )

        embedding_response: Final = response.json()
        embedding_headers: Final = dict(response.headers)
        returned_response: Final[EmbeddingResponse] = convert_to_model_response_object(
            response_object=embedding_response,

View on GitHub (pinned to 77b7c6c40c)