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): keep raw SDK import failure out of the realtime client error
yassin6e84ff0cb2a8
diff --git a/litellm/llms/bedrock/realtime/handler.py b/litellm/llms/bedrock/realtime/handler.pyindex fa9d4e3b850..fe3822629a7 100644--- a/litellm/llms/bedrock/realtime/handler.py+++ b/litellm/llms/bedrock/realtime/handler.py@@ -139,11 +139,12 @@ def _installed_sdk_version() -> str | None:def _sdk_import_error(installed_version: str | None, cause: ImportError) -> ImportError:install_hint: Final = "pip install 'litellm[bedrock-realtime]'"requirement: Final = f"{BEDROCK_REALTIME_SDK_DISTRIBUTION}[awscrt]{BEDROCK_REALTIME_SDK_SUPPORTED_RANGE}"+ verbose_proxy_logger.error("Bedrock Realtime: SDK import failed (installed=%s): %s", installed_version, cause)if installed_version is None:return ImportError(f"Missing aws_sdk_bedrock_runtime: {install_hint} ({requirement})")return ImportError(f"{BEDROCK_REALTIME_SDK_DISTRIBUTION} {installed_version} is installed but Bedrock realtime needs "- f"[awscrt]{BEDROCK_REALTIME_SDK_SUPPORTED_RANGE}: {install_hint}. Import failed with: {cause}"+ f"[awscrt]{BEDROCK_REALTIME_SDK_SUPPORTED_RANGE}: {install_hint}")diff --git a/tests/test_litellm/llms/bedrock/realtime/test_bedrock_realtime_handler.py b/tests/test_litellm/llms/bedrock/realtime/test_bedrock_realtime_handler.pyindex c2000e6cd50..21838759acd 100644--- a/tests/test_litellm/llms/bedrock/realtime/test_bedrock_realtime_handler.py+++ b/tests/test_litellm/llms/bedrock/realtime/test_bedrock_realtime_handler.py@@ -995,6 +995,9 @@ class TestBedrockRealtimeSdkImportErrors:assert "aws-sdk-bedrock-runtime 0.7.0 is installed but" in messageassert ">=0.10.0,<0.12.0" in messageassert not message.startswith("Missing aws_sdk_bedrock_runtime")+ assert isinstance(exc_info.value.__cause__, ImportError)+ assert str(exc_info.value.__cause__) not in message+ assert "cannot import name" not in messageclose_reason = message.encode()[:WEBSOCKET_CLOSE_REASON_MAX_BYTES].decode()assert "0.7.0 is installed" in close_reasonassert BEDROCK_REALTIME_SDK_SUPPORTED_RANGE in close_reason