Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(openai.py): fix position of invalid_params param

Krrish Dholakiadd2ea72cb4f6
diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py
index 459c1d93704..3db001183df 100644
--- a/litellm/llms/openai.py
+++ b/litellm/llms/openai.py
@@ -964,9 +964,9 @@ class OpenAIChatCompletion(BaseLLM):
except openai.UnprocessableEntityError as e:
## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800
if litellm.drop_params is True or drop_params is True:
+ invalid_params: List[str] = []
if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore
detail = e.body.get("detail") # type: ignore
- invalid_params: List[str] = []
if (
isinstance(detail, List)
and len(detail) > 0
@@ -1096,9 +1096,9 @@ class OpenAIChatCompletion(BaseLLM):
except openai.UnprocessableEntityError as e:
## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800
if litellm.drop_params is True or drop_params is True:
+ invalid_params: List[str] = []
if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore
detail = e.body.get("detail") # type: ignore
- invalid_params: List[str] = []
if (
isinstance(detail, List)
and len(detail) > 0
@@ -1227,9 +1227,9 @@ class OpenAIChatCompletion(BaseLLM):
except openai.UnprocessableEntityError as e:
## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800
if litellm.drop_params is True or drop_params is True:
+ invalid_params: List[str] = []
if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore
detail = e.body.get("detail") # type: ignore
- invalid_params: List[str] = []
if (
isinstance(detail, List)
and len(detail) > 0
diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py
index 6c055300606..7c3c7e80fbc 100644
--- a/litellm/llms/prompt_templates/factory.py
+++ b/litellm/llms/prompt_templates/factory.py
@@ -243,13 +243,13 @@ def mistral_api_pt(messages):
if k not in special_keys:
extra_args[k] = v
texts = ""
- if isinstance(m["content"], list):
+ if m.get("content", None) is not None and isinstance(m["content"], list):
for c in m["content"]:
if c["type"] == "image_url":
return messages
elif c["type"] == "text" and isinstance(c["text"], str):
texts += c["text"]
- elif isinstance(m["content"], str):
+ elif m.get("content", None) is not None and isinstance(m["content"], str):
texts = m["content"]
new_m = {"role": m["role"], "content": texts, **extra_args}
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index 2e71d4c827b..96a0242a8e4 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -2,6 +2,3 @@ model_list:
- model_name: "*"
litellm_params:
model: "*"
-
-litellm_settings:
- callbacks: ["openmeter"]