{"record":{"id":"732cdcc1d93119e7","repo":"openai/openai-python","slug":"you-need-to-install-openai-realtime-to-use-this-732cdc","errorCode":null,"errorMessage":"You need to install `openai[realtime]` to use this method","messagePattern":"You need to install `openai\\[realtime\\]` to use this method","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/beta/responses/responses.py","lineNumber":4519,"sourceCode":"            initial_delay=self.__initial_delay,\n            max_delay=self.__max_delay,\n            extra_query=self.__extra_query,\n            extra_headers=self.__extra_headers,\n            send_queue=self.__send_queue,\n        )\n\n        self.__event_handler_registry.merge_into(self.__connection._event_handler_registry)\n        await self.__connection._flush_send_queue()\n\n        return self.__connection\n\n    enter = __aenter__\n\n    async def _connect_ws(self, extra_query: Query, extra_headers: Headers) -> AsyncWebSocketConnection:\n        try:\n            from ....lib._websocket import _WebSocketConnect as connect\n        except ImportError as exc:\n            raise OpenAIError(\"You need to install `openai[realtime]` to use this method\") from exc\n\n        url = self._prepare_url().copy_with(\n            params={\n                **self.__client.base_url.params,\n                **extra_query,\n            },\n        )\n        log.debug(\"Connecting to WebSocket API\")\n        if self.__websocket_connection_options:\n            log.debug(\"Custom WebSocket connection options provided\")\n\n        return await connect(\n            str(url),\n            user_agent_header=self.__client.user_agent,\n            additional_headers=_merge_mappings(\n                {\n                    **self.__client.auth_headers,\n                },","sourceCodeStart":4501,"sourceCodeEnd":4537,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/beta/responses/responses.py#L4501-L4537","documentation":"The async WebSocket connection helper for BetaResponses failed to import the websockets library, which is an optional dependency shipped under the `realtime` extra. Without it the SDK cannot open the ws:// connection and raises OpenAIError before any network activity.","triggerScenarios":"Using the async BetaResponses WebSocket (client.beta.responses.connect(...)) without `websockets` installed, e.g. after installing plain `openai` instead of `openai[realtime]`, or in a slim Docker image that prunes extras.","commonSituations":"Distroless/minimal containers, dependency resolution dropping extras, teams upgrading openai and not noticing the realtime feature moved behind an optional extra.","solutions":["Install the extra: pip install \"openai[realtime]\" (or uv add 'openai[realtime]' / poetry add 'openai[realtime]')","Rebuild/refresh the environment after installation (uv sync --extra realtime, recreate the venv)","Verify with python -c \"import websockets\" that the dependency is present"],"exampleFix":"# before\npip install openai\n# after\npip install \"openai[realtime]\"","handlingStrategy":"validation","validationCode":"try:\n    import websockets  # noqa: F401\nexcept ImportError:\n    raise SystemExit(\"Install with: pip install 'openai[realtime]'\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install openai[realtime] in any environment using WebSocket features","Include extras in requirements.txt/pyproject and container images"],"tags":["python","dependency","websocket","realtime","install"],"backgroundTag":"missing-optional-dependency","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}