fix: pass encoding_format="float" in LiteLLM SDK embedding calls#434
Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom Feb 25, 2026
Merged
Conversation
DeepInfra rejects requests when encoding_format is null. LiteLLM sets it to None by default, so we explicitly pass "float" — the only format compatible with our list[list[float]] return type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
encoding_format="float"in alllitellm.embedding()/litellm.aembedding()calls inLiteLLMSDKEmbeddingsencoding_formatisnull/Noneencoding_formattoNoneto prevent the OpenAI SDK from using"base64", but thisNonevalue causes 400 errors on providers that validate the fieldProblem
When using DeepInfra embedding models (e.g.,
Qwen/Qwen3-Embedding-8B,BAAI/bge-small-en-v1.5) via thelitellm-sdkprovider, requests fail with:This happens because:
encoding_format=Nonewhen not specified (source) to override OpenAI SDK's default of"base64"null— it only accepts"float"or"base64"This is a known issue across the ecosystem: microsoft/graphrag#2194, BerriAI/litellm#12110, RooCodeInc/Roo-Code#7199.
Fix
Pass
encoding_format="float"explicitly. This is always safe becauseLiteLLMSDKEmbeddings.encode()returnslist[list[float]]— float is the only compatible format.Test plan
encoding_format="float"is passedcd hindsight-api && uv run pytest tests/test_litellm_sdk_embeddings.py -v🤖 Generated with Claude Code