fix: pass encoding_format='float' in OpenAI embeddings for proxy compatibility#4058
Merged
whysosaket merged 1 commit intomem0ai:mainfrom Mar 18, 2026
Conversation
…atibility (mem0ai#4057) The OpenAI Python SDK defaults to encoding_format='base64' when not specified, which breaks OpenAI-compatible proxies (OpenRouter, LiteLLM, vLLM, etc.) that don't support base64 decoding. This causes intermittent 'ValueError: No embedding data received' errors for users pointing openai_base_url at non-OpenAI providers. Explicitly passing encoding_format='float' ensures compatibility with all providers while producing identical results.
Contributor
Author
|
Hi! Just checking in on this PR. Let me know if there's anything you'd like me to change or any feedback on the approach. Happy to adjust! |
kartik-mem0
approved these changes
Mar 18, 2026
Contributor
kartik-mem0
left a comment
There was a problem hiding this comment.
thank you for your contribution @AtharvaJaiswal005
the solution lgtm!
3 tasks
whysosaket
approved these changes
Mar 18, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4057
Summary
encoding_format="float"toembeddings.create()call inmem0/embeddings/openai.pyencoding_format="base64"when not specified (confirmed by OpenAI), which breaks OpenAI-compatible proxies (OpenRouter, LiteLLM, vLLM, Ollama) that don't support base64 decodingValueError: No embedding data receivederrors when usingopenai_base_urlwith non-OpenAI providersChanges
mem0/embeddings/openai.py- addedencoding_format="float"to theembeddings.create()calltests/embeddings/test_openai_embeddings.py- updated existing test assertions and added a new test verifying encoding format is always passedTest plan
encoding_format="float"works with all providers including direct OpenAI API