Skip to content

fix: use correct client type for Azure embeddings in file processor - #3164

Open
theonlypal wants to merge 1 commit into
letta-ai:mainfrom
theonlypal:fix/azure-embedding-404
Open

fix: use correct client type for Azure embeddings in file processor#3164
theonlypal wants to merge 1 commit into
letta-ai:mainfrom
theonlypal:fix/azure-embedding-404

Conversation

@theonlypal

Copy link
Copy Markdown

Relevant issues

Fixes #3163 - Azure embedding requests return 404 due to malformed URL construction.

Summary

The OpenAIEmbedder was hardcoded to always use OpenAIClient regardless of the embedding_endpoint_type in the config. This caused Azure embedding requests to fail with 404 errors because:

  1. OpenAIClient._prepare_client_kwargs_embedding() uses embedding_endpoint as base_url for AsyncOpenAI
  2. For Azure, embedding_endpoint contains the full deployment URL with /embeddings path already included
  3. The OpenAI SDK appends /embeddings again, resulting in a malformed URL like:
    https://.../deployments/model/embeddings?api-version=.../embeddings

Fix: Use LLMClient.create() with the provider_type from embedding config so Azure configs get AzureClient (which handles Azure URLs correctly via AsyncAzureOpenAI).

Pre-Submission checklist

  • I have added testing in the tests/ directory
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

  • Modified OpenAIEmbedder.__init__() to use ProviderType(embedding_config.embedding_endpoint_type) instead of hardcoded ProviderType.openai
  • Added regression tests verifying correct client selection for both Azure and OpenAI configs

The OpenAIEmbedder was hardcoded to always use OpenAIClient regardless
of the embedding_endpoint_type in the config. This caused Azure embedding
requests to fail with 404 errors because:

1. OpenAIClient._prepare_client_kwargs_embedding() uses embedding_endpoint
   as base_url for AsyncOpenAI
2. For Azure, embedding_endpoint contains the full deployment URL with
   /embeddings path already included
3. OpenAI SDK appends /embeddings again, resulting in malformed URL

Fix: Use LLMClient.create() with the provider_type from embedding config
so Azure configs get AzureClient (which handles Azure URLs correctly).

Fixes letta-ai#3163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure embedding requests return 404 - malformed URL construction

1 participant