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(bedrock_httpx.py): raise bad request error if invalid bedrock model given
Krrish Dholakia66d77f177f90
diff --git a/litellm/llms/bedrock_httpx.py b/litellm/llms/bedrock_httpx.pyindex 3434371f6ee..ffc096f762e 100644--- a/litellm/llms/bedrock_httpx.py+++ b/litellm/llms/bedrock_httpx.py@@ -1054,10 +1054,11 @@ class BedrockLLM(BaseLLM):"complete_input_dict": inference_params,},)- raise Exception(- "Bedrock HTTPX: Unsupported provider={}, model={}".format(+ raise BedrockError(+ status_code=400,+ message="Bedrock HTTPX: Unsupported provider={}, model={}".format(provider, model- )+ ),)## COMPLETION CALLdiff --git a/litellm/tests/test_bedrock_completion.py b/litellm/tests/test_bedrock_completion.pyindex 5f49bbd2c6c..4da18144d08 100644--- a/litellm/tests/test_bedrock_completion.py+++ b/litellm/tests/test_bedrock_completion.py@@ -1157,3 +1157,16 @@ def test_bedrock_tools_pt_invalid_names():assert len(result) == 2assert result[0]["toolSpec"]["name"] == "a123_invalid_name"assert result[1]["toolSpec"]["name"] == "another_invalid_name"+++def test_bad_request_error():+ with pytest.raises(litellm.BadRequestError):+ completion(+ model="bedrock/bad_model",+ messages=[+ {+ "role": "user",+ "content": "What is the meaning of life",+ }+ ],+ )