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
test_async_bad_request_bad_param_error
Ishaan Jaff3b632ac82566
diff --git a/tests/llm_responses_api_testing/test_openai_responses_api.py b/tests/llm_responses_api_testing/test_openai_responses_api.pyindex b711c93f800..37674551fed 100644--- a/tests/llm_responses_api_testing/test_openai_responses_api.py+++ b/tests/llm_responses_api_testing/test_openai_responses_api.py@@ -795,3 +795,34 @@ async def test_openai_responses_litellm_router_with_metadata():loaded_request_body["metadata"] == test_metadata), "metadata in request body should match what was passed"mock_post.assert_called_once()+++def test_bad_request_bad_param_error():+ """Raise a BadRequestError when an invalid parameter value is provided"""+ try:+ litellm.responses(model="gpt-4o", input="This should fail", temperature=2000)+ pytest.fail("Expected BadRequestError but no exception was raised")+ except litellm.BadRequestError as e:+ print(f"Exception raised: {e}")+ print(f"Exception type: {type(e)}")+ print(f"Exception args: {e.args}")+ print(f"Exception details: {e.__dict__}")+ except Exception as e:+ pytest.fail(f"Unexpected exception raised: {e}")+++async def test_async_bad_request_bad_param_error():+ """Raise a BadRequestError when an invalid parameter value is provided"""+ try:+ await litellm.aresponses(+ model="gpt-4o", input="This should fail", temperature=2000+ )+ pytest.fail("Expected BadRequestError but no exception was raised")+ except litellm.BadRequestError as e:+ print(f"Exception raised: {e}")+ print(f"Exception type: {type(e)}")+ print(f"Exception args: {e.args}")+ print(f"Exception details: {e.__dict__}")+ except Exception as e:+ pytest.fail(f"Unexpected exception raised: {e}")diff --git a/tests/openai_endpoints_tests/test_openai_responses_api.py b/tests/openai_endpoints_tests/test_openai_responses_api.pyindex f853d53532a..1dde8ebae6b 100644--- a/tests/openai_endpoints_tests/test_openai_responses_api.py+++ b/tests/openai_endpoints_tests/test_openai_responses_api.py@@ -97,3 +97,12 @@ def test_bad_request_error():with pytest.raises(BadRequestError):# Trigger error with invalid model nameclient.responses.create(model="non-existent-model", input="This should fail")+++def test_bad_request_bad_param_error():+ client = get_test_client()+ with pytest.raises(BadRequestError):+ # Trigger error with invalid model name+ client.responses.create(+ model="gpt-4o", input="This should fail", temperature=2000+ )