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]

Update litellm/llms/openai/responses/count_tokens/handler.py

Cesar Garcia92b0585f2e95
diff --git a/litellm/llms/openai/responses/count_tokens/handler.py b/litellm/llms/openai/responses/count_tokens/handler.py
index e417dbd2a63..721d07796ee 100644
--- a/litellm/llms/openai/responses/count_tokens/handler.py
+++ b/litellm/llms/openai/responses/count_tokens/handler.py
@@ -97,7 +97,7 @@ class OpenAICountTokensHandler(OpenAICountTokensConfig):
status_code=e.response.status_code,
message=e.response.text,
)
- except (httpx.RequestError, json.JSONDecodeError) as e:
+ except (httpx.RequestError, json.JSONDecodeError, ValueError) as e:
verbose_logger.error(f"Error in CountTokens handler: {str(e)}")
raise OpenAIError(
status_code=500,