{"record":{"id":"d18f94a9eb3fbafd","repo":"BerriAI/litellm","slug":"api-version-is-required-for-azure-openai-calls","errorCode":null,"errorMessage":"api_version is required for Azure OpenAI calls","messagePattern":"api_version is required for Azure OpenAI calls","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/realtime/handler.py","lineNumber":110,"sourceCode":"        api_base: str | None = None,\n        api_key: str | None = None,\n        api_version: str | None = None,\n        azure_ad_token: str | None = None,\n        client: Any | None = None,\n        timeout: float | None = None,\n        realtime_protocol: str | None = None,\n        query_params: RealtimeQueryParams | None = None,\n        user_api_key_dict: Any | None = None,\n        litellm_metadata: dict | None = None,\n    ):\n        import websockets\n        from websockets.asyncio.client import ClientConnection\n\n        if api_base is None:\n            raise ValueError(\"api_base is required for Azure OpenAI calls\")\n        backend_uses_beta_protocol: Final = realtime_protocol is None or realtime_protocol.upper() not in (\"GA\", \"V1\")\n        if api_version is None and backend_uses_beta_protocol:\n            raise ValueError(\"api_version is required for Azure OpenAI calls\")\n\n        url: Final = self._construct_url(\n            api_base,\n            model,\n            api_version,\n            realtime_protocol=realtime_protocol,\n            query_params=query_params,\n        )\n\n        try:\n            ssl_context: Final = get_shared_realtime_ssl_context()\n            async with websockets.connect(\n                url,\n                additional_headers={\n                    \"api-key\": api_key,\n                },\n                max_size=REALTIME_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES,\n                ssl=ssl_context,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/realtime/handler.py#L92-L128","documentation":"For the Azure Realtime API, when realtime_protocol is None or not 'GA'/'V1' (i.e. the beta protocol), Azure requires an explicit api_version query parameter in the WebSocket URL. This ValueError fires when api_version is None and the beta protocol is selected, before the connection attempt. Only the GA/V1 protocol omits the version from the URL.","triggerScenarios":"Connecting with realtime_protocol=None (default beta) and api_version unset; upgrading litellm after older previews defaulted a version; explicitly passing realtime_protocol='beta' without an api_version.","commonSituations":"Copy-pasted realtime examples that omit api_version; Azure preview API versions being retired so previously hardcoded values were removed; teams switching between GA and beta realtime endpoints and dropping the version argument.","solutions":["Pass an api_version your Azure resource supports, e.g. api_version='2024-10-01-preview'.","Or pass realtime_protocol='GA' (or 'V1') if your deployment is on the GA realtime endpoint, which does not need api_version.","Pin the api_version in config rather than relying on defaults across litellm upgrades."],"exampleFix":"# before\nawait azure_realtime.connect(model='azure/voice', api_key=k, api_base=base)  # beta default, no version -> raises\n\n# after (beta protocol, explicit version)\nawait azure_realtime.connect(model='azure/voice', api_key=k, api_base=base, api_version='2024-10-01-preview')\n\n# after (GA protocol, version not required)\nawait azure_realtime.connect(model='azure/voice', api_key=k, api_base=base, realtime_protocol='GA')","handlingStrategy":"validation","validationCode":"def validate_realtime_version(api_version: str | None, realtime_protocol: str | None) -> None:\n    beta = realtime_protocol is None or realtime_protocol.upper() not in ('GA', 'V1')\n    if beta and not api_version:\n        raise ValueError('pass api_version (e.g. 2024-10-01-preview) or use realtime_protocol=\"GA\"')","typeGuard":null,"tryCatchPattern":"try:\n    await handler.connect(...)\nexcept ValueError as e:\n    if 'api_version is required' in str(e):\n        raise ValueError('pin an Azure realtime api_version or switch to the GA protocol') from e\n    raise","preventionTips":["Pin api_version explicitly instead of relying on library defaults across upgrades.","Track Azure realtime API version announcements; preview versions get retired.","If on the GA endpoint, declare realtime_protocol='GA' to drop the version requirement."],"tags":["azure","openai","realtime","websocket","api-version","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}