litellm - ✅(Solved) Fix [Bug] LiteLLM sends encoding_format: None causing Gitee AI and SiliconFlow API errors [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25388Fetched 2026-04-09 07:52:20
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Error Message

APIError: GiteeAIException - Internal Server Error

Root Cause

The root cause is that LiteLLM sends encoding_format: null (None) in the embedding API request, but these providers expect either encoding_format: "float" or no encoding_format parameter at all.

Fix Action

Fix / Workaround

  • This affects redisvl library which uses LiteLLM for embeddings
  • The issue occurs in both sync and async embedding calls
  • Workaround: Use pydantic settings to drop unsupported parameters (litellm.drop_params = True)

PR fix notes

PR #25395: fix(embedding): omit null encoding_format for openai requests

Description (problem / solution / changelog)

Relevant issues

Fixes #25388

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🐛 Bug Fix ✅ Test

Changes

  • Stop sending encoding_format: null in embedding requests when it is not set.
  • Preserve explicit encoding_format values (for example, "float").
  • Add regression tests for both behaviors (unset omitted, explicit preserved).

Changed files

  • litellm/main.py (modified, +0/-3)
  • tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py (added, +34/-0)

PR #25428: fix(embeddings): only set encoding_format=None for canonical OpenAI provider

Description (problem / solution / changelog)

Changes

Fix — `encoding_format=null` sent to third-party providers (closes #25388)

`litellm/main.py` unconditionally set `optional_params["encoding_format"] = None` when no `encoding_format` was provided, even for providers like `together_ai` and `nvidia_nim` that share the same embedding code path. These providers reject the `null` value with a 400 error (e.g. Gitee AI, SiliconFlow).

The `None` sentinel exists to prevent the OpenAI Python SDK from injecting its own default of `"float"` — but this is only relevant for the canonical OpenAI provider. Scoping it to `custom_llm_provider == "openai"` (or `None` for the `open_ai_embedding_models` fallback) leaves third-party providers unaffected.

# before — None sent to all providers in this branch
if encoding_format is not None:
    optional_params["encoding_format"] = encoding_format
else:
    # Omiting causes openai sdk to add default value of "float"
    optional_params["encoding_format"] = None

# after — None only set for canonical OpenAI
if encoding_format is not None:
    optional_params["encoding_format"] = encoding_format
elif custom_llm_provider == "openai" or custom_llm_provider is None:
    # Omitting causes openai sdk to add default value of "float".
    # Only suppress for the canonical OpenAI provider — third-party
    # providers (together_ai, nvidia_nim, etc.) reject encoding_format=null.
    optional_params["encoding_format"] = None

Test plan

  • together_ai embedding call with no encoding_formatencoding_format key absent from params sent to provider
  • nvidia_nim embedding call with no encoding_formatencoding_format key absent from params
  • openai embedding call with no encoding_formatencoding_format=None still set (preserves existing SDK behaviour)
  • Explicit encoding_format="float" always forwarded regardless of provider

Changed files

  • litellm/main.py (modified, +4/-2)
  • tests/test_litellm/test_utils.py (modified, +59/-16)

Code Example

APIError: GiteeAIException - Internal Server Error
RAW_BUFFERClick to expand / collapse

Bug Description

LiteLLM sends encoding_format: None in embedding requests, causing Gitee AI and SiliconFlow API to reject requests with errors.

Error Details

When using LiteLLM with Gitee AI or SiliconFlow providers for embeddings, the following error occurs:

APIError: GiteeAIException - Internal Server Error

The root cause is that LiteLLM sends encoding_format: null (None) in the embedding API request, but these providers expect either encoding_format: "float" or no encoding_format parameter at all.

Affected Providers

  1. Gitee AI (https://ai.gitee.com/v1)
  2. SiliconFlow (https://api.siliconflow.cn/v1)

Reproduction Steps

  1. Configure LiteLLM with Gitee AI or SiliconFlow provider
  2. Try to generate embeddings using any embedding model
  3. Observe the API error response

Expected Behavior

LiteLLM should either:

  • Not send encoding_format parameter when it's None
  • Send encoding_format: "float" as the default

Additional Context

  • This affects redisvl library which uses LiteLLM for embeddings
  • The issue occurs in both sync and async embedding calls
  • Workaround: Use pydantic settings to drop unsupported parameters (litellm.drop_params = True)

Version

  • LiteLLM: v1.80+ (tested on v1.80.x)

extent analysis

TL;DR

Set litellm.drop_params = True to drop unsupported parameters, including the problematic encoding_format: None, as a workaround.

Guidance

  • Verify that the issue is indeed caused by the encoding_format: None parameter by checking the API request payload sent by LiteLLM.
  • Use pydantic settings to drop unsupported parameters by setting litellm.drop_params = True, as mentioned in the Additional Context.
  • Test the workaround with both Gitee AI and SiliconFlow providers to ensure it resolves the issue for both.
  • Consider updating the LiteLLM configuration to send encoding_format: "float" as the default, if possible, to align with the expected behavior.

Example

No code snippet is provided as it is not explicitly mentioned in the issue, but the workaround can be applied using pydantic settings.

Notes

This workaround may have unintended consequences, such as dropping other important parameters. It is essential to test the workaround thoroughly to ensure it does not introduce new issues.

Recommendation

Apply the workaround by setting litellm.drop_params = True, as it is a simple and effective solution to mitigate the issue, and it is explicitly mentioned in the Additional Context as a viable workaround.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING