Skip to content

[Bug]: Azure OpenAI Embeddings Always Return 404 Due to Wrong Variable Passed to API #2394

@Amrit75

Description

@Amrit75

Do you need to file an issue?

  • I have searched the existing issues and this bug is not already filed.
  • I believe this is a legitimate bug, not just a question or feature request.

Describe the bug

The Azure embeddings client in LightRAG always returns a 404 Resource Not Found error because the function azure_openai_embed() passes the wrong value to the model parameter in the embeddings API call.

Although the function correctly resolves the Azure deployment name into the deployment variable, it mistakenly calls the embeddings API with:model=model

The model parameter is almost always None, causing Azure to look for a deployment literally named "None", which leads to a 404 error.

The correct value should be: model=deployment

This issue occurs even when all Azure environment variables and deployments are correctly configured.

Steps to reproduce

  1. Set up environment variables for Azure embeddings:
AZURE_EMBEDDING_ENDPOINT=https://<your-resource>.openai.azure.com/
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-3-small
AZURE_EMBEDDING_API_KEY=<your-key>
AZURE_EMBEDDING_API_VERSION=2023-05-15

  1. Run any LightRAG example that uses embeddings,

  2. LightRAG attempts to call Azure embeddings.

  3. Azure returns the following error: 404: DeploymentNotFound - The deployment 'None' does not exist Tracing this shows that the embeddings client received model=None instead of the actual deployment name.

Expected Behavior

LightRAG should call embeddings.create() using the resolved Azure deployment name, and embeddings should be generated successfully without a 404 error.
The line: model=model
should instead use:model=deployment

LightRAG Config Used

In .env File

AZURE_EMBEDDING_ENDPOINT=https://<your-resource>.openai.azure.com/
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-3-small
AZURE_EMBEDDING_API_KEY=<your-key>
AZURE_EMBEDDING_API_VERSION=2023-05-15

Example :

LightRAG(
        working_dir=str(WORKING_DIR),
        llm_model_func=azure_openai_complete,
        embedding_func=azure_openai_embed,
) 

Logs and screenshots

openai.BadRequestError: 404 - DeploymentNotFound
Message: The API deployment for 'None' does not exist

Additional Information

  • LightRAG Version: 1.4.9.8
  • Operating System: MacOS
  • Python Version: 3.11
  • Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions