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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix openai tests
yuneng-jiange49d0946066e
diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.pyindex 0974830324f..e546a0dbb02 100644--- a/litellm/completion_extras/litellm_responses_transformation/transformation.py+++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py@@ -296,8 +296,12 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):request_data["instructions"] = instructionselif key == "stream_options" and isinstance(value, dict):request_data["stream_options"] = value.get("include_obfuscation")- elif key == "user" and isinstance(value, str) and len(value) <= 64:- request_data["user"] = value+ elif key == "user" and isinstance(value, str):+ # OpenAI API requires user param to be max 64 chars - truncate if longer+ if len(value) <= 64:+ request_data["user"] = value+ else:+ request_data["user"] = value[:64]else:request_data[key] = valuediff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.pyindex 03fbdd463dd..dde44cced36 100644--- a/litellm/litellm_core_utils/exception_mapping_utils.py+++ b/litellm/litellm_core_utils/exception_mapping_utils.py@@ -70,6 +70,11 @@ class ExceptionCheckers:Check if an error string indicates a context window exceeded error."""_error_str_lowercase = error_str.lower()+ # Exclude param validation errors (e.g. OpenAI "user" param max 64 chars)+ if "string_above_max_length" in _error_str_lowercase:+ return False+ if "invalid 'user'" in _error_str_lowercase and "string too long" in _error_str_lowercase:+ return Falseknown_exception_substrings = ["exceed context limit","this model's maximum context length is",diff --git a/tests/llm_translation/test_openai.py b/tests/llm_translation/test_openai.pyindex 6a2ad406788..eff11c9cee3 100644--- a/tests/llm_translation/test_openai.py+++ b/tests/llm_translation/test_openai.py@@ -519,7 +519,7 @@ async def test_openai_codex_stream(sync_mode):from litellm.main import stream_chunk_builderkwargs = {- "model": "openai/codex-mini-latest",+ "model": "openai/gpt-5-codex-mini","messages": [{"role": "user", "content": "Hey!"}],"stream": True,}@@ -549,16 +549,16 @@ async def test_openai_codex(sync_mode):router = Router(model_list=[{- "model_name": "openai-codex-mini-latest",+ "model_name": "openai-gpt-5-codex-mini","litellm_params": {- "model": "openai/codex-mini-latest",+ "model": "openai/gpt-5-codex-mini",},}])kwargs = {- "model": "openai-codex-mini-latest",+ "model": "openai-gpt-5-codex-mini","messages": [{"role": "user", "content": "Hey!"}],}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.pyindex c7ad18cfb0c..beb978584cb 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@@ -77,6 +77,15 @@ context_window_test_cases = [("Rate limit reached for requests.", False),("The context is large, but acceptable.", False),("", False), # Empty string+ # OpenAI user param length validation - not a context window error+ (+ "Invalid 'user': string too long. Expected a string with maximum length 64, but got a string with length 123 instead.",+ False,+ ),+ (+ '{"error": {"message": "Invalid \'user\': string too long.", "code": "string_above_max_length"}}',+ False,+ ),]