{"record":{"id":"36ddad798aa703a1","repo":"microsoft/semantic-kernel","slug":"the-openai-realtime-model-id-is-required-36ddad","errorCode":null,"errorMessage":"The OpenAI realtime model ID is required.","messagePattern":"The OpenAI realtime model ID is required\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"critical","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/open_ai_realtime.py","lineNumber":100,"sourceCode":"                This can include:\n                kernel (Kernel): the kernel to use for function calls\n                plugins (list[object] or dict[str, object]): the plugins to use for function calls\n                settings (OpenAIRealtimeExecutionSettings): the settings to use for the session\n                chat_history (ChatHistory): the chat history to use for the session\n                Otherwise they can also be passed to the context manager.\n        \"\"\"\n        try:\n            openai_settings = OpenAISettings(\n                api_key=api_key,\n                org_id=org_id,\n                realtime_model_id=ai_model_id,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(\"Failed to create OpenAI settings.\", ex) from ex\n        if not openai_settings.realtime_model_id:\n            raise ServiceInitializationError(\"The OpenAI realtime model ID is required.\")\n        if audio_track:\n            kwargs[\"audio_track\"] = audio_track\n        super().__init__(\n            audio_output_callback=audio_output_callback,\n            ai_model_id=openai_settings.realtime_model_id,\n            service_id=service_id,\n            api_key=openai_settings.api_key.get_secret_value() if openai_settings.api_key else None,\n            org_id=openai_settings.org_id,\n            ai_model_type=OpenAIModelTypes.REALTIME,\n            default_headers=default_headers,\n            client=client,\n            **kwargs,\n        )\n\n\n# region Websocket\n\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/open_ai_realtime.py#L82-L118","documentation":"Raised during OpenAIRealtimeWebRTC construction when the resolved OpenAISettings has a falsy realtime_model_id. After settings are successfully created, the constructor verifies a realtime model name exists — every WebRTC realtime session requires a model id to negotiate the connection.","triggerScenarios":"Instantiating OpenAIRealtimeWebRTC without passing ai_model_id AND without setting OPENAI_REALTIME_MODEL_ID in the environment or .env file. The realtime_model_id on OpenAISettings resolves to None or an empty string.","commonSituations":"Using the realtime API for the first time without adding the realtime model env var; the env var name differs from what OpenAISettings expects; passing ai_model_id as a positional argument that maps to the wrong parameter.","solutions":["Set the OPENAI_REALTIME_MODEL_ID environment variable (e.g., gpt-4o-realtime-preview)","Pass ai_model_id explicitly: OpenAIRealtimeWebRTC(audio_track=track, ai_model_id='gpt-4o-realtime-preview')","Verify the .env file contains the realtime model key if loading from env"],"exampleFix":"# before\nservice = OpenAIRealtimeWebRTC(audio_track=track, api_key=key)\n# after\nservice = OpenAIRealtimeWebRTC(\n    audio_track=track,\n    api_key=key,\n    ai_model_id='gpt-4o-realtime-preview',\n)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.open_ai import OpenAISettings\n\nsettings = OpenAISettings()\nif not settings.realtime_model_id:\n    raise ValueError('OPENAI_REALTIME_MODEL_ID is not set')","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    service = OpenAIRealtimeWebRTC(audio_track=track)\nexcept ServiceInitializationError as e:\n    if 'realtime model ID' in str(e):\n        raise  # deployment config issue","preventionTips":["Add OPENAI_REALTIME_MODEL_ID to your .env alongside OPENAI_API_KEY","Add a startup check for all required realtime settings before entering a WebRTC session"],"tags":["openai","realtime","webrtc","configuration","model-id"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}