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]

Add context window exception mapping for Together AI (#17284)

Boxuan Li89458573a232
diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py
index f8c786daef3..056522e2a64 100644
--- a/litellm/litellm_core_utils/exception_mapping_utils.py
+++ b/litellm/litellm_core_utils/exception_mapping_utils.py
@@ -77,6 +77,7 @@ class ExceptionCheckers:
"model's maximum context limit",
"is longer than the model's context length",
"input tokens exceed the configured limit",
+ "`inputs` tokens + `max_new_tokens` must be",
]
for substring in known_exception_substrings:
if substring in _error_str_lowercase:
diff --git a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
index d7da7592870..d59e52d965e 100644
--- a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
+++ b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
@@ -36,6 +36,10 @@ context_window_test_cases = [
"Input tokens exceed the configured limit of 272000 tokens. Your messages resulted in 509178 tokens. Please reduce the length of the messages.",
True,
),
+ (
+ "`inputs` tokens + `max_new_tokens` must be <= 4096",
+ True,
+ ),
# Test case insensitivity
("ERROR: THIS MODEL'S MAXIMUM CONTEXT LENGTH IS 1024.", True),
# Negative cases (should return False)