Skip to content

fix: prevent embedding 422 on strict OpenAI-compatible endpoints (DeepInfra, vLLM, TEI)#1430

Closed
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/embedding-encoding-format-null
Closed

fix: prevent embedding 422 on strict OpenAI-compatible endpoints (DeepInfra, vLLM, TEI)#1430
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/embedding-encoding-format-null

Conversation

@PaoloC68
Copy link
Copy Markdown
Contributor

@PaoloC68 PaoloC68 commented Apr 3, 2026

Fixes #1429

Summary

LiteLLM ≥1.80.11 sends encoding_format: null in embedding requests when the parameter is not explicitly set. Strict OpenAI-compatible validators (DeepInfra, vLLM, HuggingFace TEI) reject null with a 422 error. This fix sets "float" as the default — the OpenAI spec default — before merging caller kwargs, so any explicitly configured value still takes precedence.

Changes

File Change
models.py embed_documents and embed_query: build embed_kwargs with encoding_format="float" default before **self.kwargs

Testing

Tested on helpa0.com with DeepInfra embedding provider (openai/BAAI/bge-m3) and LiteLLM 1.82.3. Memory search and recall both work correctly after the fix.

Upstream LiteLLM issue: BerriAI/litellm#19174
Partial upstream fix (openai_like handler only): BerriAI/litellm#20056
Pending upstream fix (openai handler): BerriAI/litellm#24277

LiteLLM >=1.80.11 sends encoding_format=null in embedding requests when the
parameter is not explicitly set (BerriAI/litellm#19174). Strict validators
such as DeepInfra, vLLM, and HuggingFace TEI reject null with:

  422 Unprocessable Entity: Input should be 'float' or 'base64'

Default to 'float' (the OpenAI spec default) before merging caller kwargs,
so any explicitly configured value still takes precedence.
@PaoloC68
Copy link
Copy Markdown
Contributor Author

PaoloC68 commented Apr 4, 2026

Superseded by #1437 which combines both embedding fixes (encoding_format null + context window truncation) in a single clean PR.

@PaoloC68 PaoloC68 closed this Apr 4, 2026
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.

1 participant