BerriAI/litellm · error · Exception

/image/embeddings route returned None Embeddings.

Error message

/image/embeddings route returned None Embeddings.

What it means

In the async Azure AI multimodal embedding flow, after the /images/embeddings call succeeds, LiteLLM asserts that the response's data array is populated. If response.data is None it raises a plain Exception '/image/embeddings route returned None Embeddings.' — meaning the HTTP call succeeded but the parsed EmbeddingResponse carries no vectors.

Source

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

        image_embedding_responses: list | None = None
        text_embedding_responses: list | None = None

        if image_embeddings_request["input"]:
            image_response: Final = await self.async_image_embedding(
                model=model,
                data=image_embeddings_request,
                timeout=timeout,
                logging_obj=logging_obj,
                model_response=model_response,
                optional_params=optional_params,
                api_key=api_key,
                api_base=api_base,
                client=client,
            )

            image_embedding_responses = image_response.data
            if image_embedding_responses is None:
                raise Exception("/image/embeddings route returned None Embeddings.")

        if v1_embeddings_request["input"]:
            response: Final[EmbeddingResponse] = await super().embedding(
                model=model,
                input=input,
                timeout=timeout,
                logging_obj=logging_obj,
                model_response=model_response,
                optional_params=optional_params,
                api_key=api_key,
                api_base=api_base,
                client=client,
                aembedding=True,
            )
            text_embedding_responses = response.data
            if text_embedding_responses is None:
                raise Exception("/v1/embeddings route returned None Embeddings.")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Log and inspect the raw Azure response for one failing input — confirm whether data is truly absent or the shape differs.
  2. Sanitize image inputs: pure base64, valid JPEG/PNG bytes, strip data-URI prefixes before sending.
  3. Verify the deployment is actually an image-embedding model (e.g. a multimodal embedder) and not a text embedder silently ignoring images.
  4. If the raw response contains vectors but litellm returns None, update litellm — likely a parser fix.

Example fix

# before
litellm.aembedding(model='azure_ai/mm-embed', input=['data:image/png;base64,' + b64])

# after
import base64, re
raw = re.sub(r'^data:image/\w+;base64,', '', data_uri)
litellm.aembedding(model='azure_ai/mm-embed', input=[raw])
Defensive patterns

Strategy: validation

Validate before calling

import base64, re

def clean_image_b64(img: str) -> str:
    raw = re.sub(r'^data:image/[a-zA-Z]+;base64,', '', img).replace('\n', '')
    base64.b64decode(raw, validate=True)  # raises on bad input before the API call
    return raw

Try / catch

try:
    resp = await litellm.aembedding(model='azure_ai/mm-embed', input=[clean_image_b64(i) for i in imgs])
except Exception as e:
    if 'returned None Embeddings' in str(e):
        drop_and_alert_bad_inputs(imgs)  # keep pipeline alive, flag offending batch
        raise
    raise

Prevention

When it happens

Trigger: aembedding() with images in input where Azure returns 200 but an empty/None data field: malformed base64 image, image format the model can't embed, or an API/schema change making litellm's parser miss the field. HTTP-level failures raise earlier, so this specifically means empty payload.

Common situations: Images encoded with data-URI prefixes ('data:image/png;base64,') not stripped; empty-string or zero-byte images after a bad decode step upstream; mismatch between deployed model (text-only) sent image input; litellm version lagging a response schema change on Azure.

Related errors


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