{"record":{"id":"d5f6f2f5c1600f06","repo":"BerriAI/litellm","slug":"error-message-d5f6f2","errorCode":null,"errorMessage":"{error_message}","messagePattern":"\\{error_message\\}","errorType":"http","errorClass":"BaseLLMException","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/realtime/transformation.py","lineNumber":44,"sourceCode":"        headers: dict,\n        model: str,\n        api_key: str | None = None,\n    ) -> dict:\n        pass\n\n    @abstractmethod\n    def get_complete_url(self, api_base: str | None, model: str, api_key: str | None = None) -> str:\n        \"\"\"\n        OPTIONAL\n\n        Get the complete url for the request\n\n        Some providers need `model` in `api_base`\n        \"\"\"\n        return api_base or \"\"\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:\n        raise BaseLLMException(\n            status_code=status_code,\n            message=error_message,\n            headers=headers,\n        )\n\n    @abstractmethod\n    def transform_realtime_request(\n        self,\n        message: str,\n        model: str,\n        session_configuration_request: str | None = None,\n    ) -> list[str]:\n        pass\n\n    def is_setup_message(self, msg_obj: dict) -> bool:\n        return False\n\n    def is_content_message(self, msg_obj: dict) -> bool:","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/realtime/transformation.py#L26-L62","documentation":"This is the realtime (websocket) error-mapping hook: get_error_class raises BaseLLMException carrying the provider's status_code, error_message and headers verbatim. Encountering it means the realtime handshake or session errored at the provider (auth, model access, quota) and the generic mapper surfaced it — the literal '{error_message}' in static analysis is just the f-string template.","triggerScenarios":"Opening a realtime session (litellm.realtime / WebSocket bridge) with an invalid API key (401/403), nonexistent model, insufficient quota, or a provider that rejects the upgrade request; the error handler calls get_error_class with the provider's message.","commonSituations":"Expired or wrong OPENAI_API_KEY for realtime; using a model without realtime capability; regional endpoint misconfiguration; proxy auth layers stripping websocket headers.","solutions":["Inspect the caught BaseLLMException.status_code and message to identify the upstream cause (fix key/model accordingly).","For 401/403: verify API key env vars and permissions for realtime APIs.","For 404/400: confirm the model name supports realtime and the api_base points at the realtime endpoint.","Override get_error_class in the provider config for typed exception mapping."],"exampleFix":"# before\ntry:\n    litellm.realtime(model='gpt-4o-realtime', listening=True)\nexcept Exception:\n    raise\n\n# after\nfrom litellm.llms.base_llm.chat.transformation import BaseLLMException\ntry:\n    litellm.realtime(model='gpt-4o-realtime', listening=True)\nexcept BaseLLMException as e:\n    logger.error('realtime failed: %s (%s)', e.message, e.status_code)\n    raise","handlingStrategy":"try-catch","validationCode":"def validate_realtime_setup(model: str, api_key: str | None, api_base: str | None) -> None:\n    if not api_key:\n        raise ConfigError('realtime requires an API key')\n    if 'realtime' not in model and 'audio' not in model:\n        warnings.warn(f'{model} may not support realtime sessions')","typeGuard":null,"tryCatchPattern":"try:\n    await litellm.realtime(...)\nexcept BaseLLMException as e:\n    if e.status_code in (401, 403):\n        raise AuthError('realtime auth failed') from e\n    if e.status_code == 429:\n        await asyncio.sleep(5)\n        return await litellm.realtime(...)\n    raise","preventionTips":["Verify API key scopes include realtime/audio models before opening sessions.","Check model capability lists rather than assuming realtime support.","Log BaseLLMException.status_code and headers for support escalation."],"tags":["realtime","websocket","error-mapping","upstream"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}