{"record":{"id":"0f5f0645ecf0f9d8","repo":"openai/openai-python","slug":"model-is-required-for-azure-realtime-api","errorCode":null,"errorMessage":"`model` is required for Azure Realtime API","messagePattern":"`model` is required for Azure Realtime API","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/realtime/realtime.py","lineNumber":698,"sourceCode":"\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        await self.__client._refresh_api_key()\n        auth_headers = self.__client.auth_headers\n        if self.__call_id is not omit:\n            extra_query = {**extra_query, \"call_id\": self.__call_id}\n        if is_async_azure_client(self.__client):\n            from ...lib._azure_websocket import _AzureWebSocketConnect as connect\n\n            model = self.__model\n            if not model:\n                raise OpenAIError(\"`model` is required for Azure Realtime API\")\n            else:\n                url, auth_headers = await self.__client._configure_realtime(model, extra_query)\n        else:\n            url = self._prepare_url().copy_with(\n                params={\n                    **self.__client.base_url.params,\n                    **({\"model\": self.__model} if self.__model is not omit else {}),\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(","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/realtime/realtime.py#L680-L716","documentation":"Raised by the async Realtime connect path when the client is an AzureOpenAI client and no `model` argument was supplied. Azure requires the deployment/model name to build the correct realtime URL and auth via _configure_realtime, so the SDK refuses to proceed without it.","triggerScenarios":"`async with AsyncOpenAI-style AzureOpenAI().beta.realtime.connect(...)` (or azure_monitor-style realtime connect) without passing model=..., or passing model=NOT_GIVEN/None.","commonSituations":"Porting OpenAI-first code to Azure and relying on a default_model set on the client (the Realtime path requires the per-call model), or forgetting that Azure uses deployment names.","solutions":["Pass the Azure deployment name explicitly: client.beta.realtime.connect(model=\"my-deployment\", ...)","Ensure the name matches the deployment created in Azure OpenAI Studio, not necessarily the underlying model id","If using multiple deployments, resolve the model per session before connecting"],"exampleFix":"# before\nasync with azure_client.beta.realtime.connect() as conn: ...\n# after\nasync with azure_client.beta.realtime.connect(model=\"gpt-4o-realtime-deploy\") as conn: ...","handlingStrategy":"validation","validationCode":"if is_azure and not (model and model.strip()):\n    raise ValueError(\"model (Azure deployment name) is required for Realtime\")","typeGuard":"def has_model(v: str | None) -> bool:\n    return bool(v and v.strip())","tryCatchPattern":"try:\n    async with azure_client.beta.realtime.connect(model=model) as conn: ...\nexcept OpenAIError as e:\n    if \"`model` is required\" in str(e):\n        model = resolve_deployment_name()\n        # retry with model","preventionTips":["Always pass the Azure deployment name to connect()","Verify deployment names in Azure OpenAI Studio","Centralize backend-specific config (OpenAI vs Azure)"],"tags":["realtime","azure","async","missing-model"],"backgroundTag":"azure-deployment-name-missing","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}