{"id":9082,"library":"livekit-plugins-azure","title":"LiveKit Azure Plugins","description":"livekit-plugins-azure is a Python plugin for the LiveKit Agents framework, providing seamless integration with Azure AI Speech services for Speech-to-Text (STT) and Text-to-Speech (TTS). It is currently at version 1.5.4 and receives frequent updates as part of the broader LiveKit Agents ecosystem.","status":"active","version":"1.5.4","language":"en","source_language":"en","source_url":"https://github.com/livekit/agents","tags":["LiveKit","Azure","STT","TTS","Speech-to-Text","Text-to-Speech","AI","Agent","Realtime Audio"],"install":[{"cmd":"pip install livekit-plugins-azure","lang":"bash","label":"Install LiveKit Azure Plugins"}],"dependencies":[{"reason":"This package is a plugin designed to extend the functionality of the LiveKit Agents framework.","package":"livekit-agents"}],"imports":[{"note":"The common pattern is to import the 'azure' module, then access STT/TTS via 'azure.STT' or 'azure.TTS'.","wrong":"from livekit.plugins.azure import STT","symbol":"STT","correct":"from livekit.plugins import azure\n# ... then use azure.STT(...)"},{"note":"The common pattern is to import the 'azure' module, then access STT/TTS via 'azure.STT' or 'azure.TTS'.","wrong":"from livekit.plugins.azure import TTS","symbol":"TTS","correct":"from livekit.plugins import azure\n# ... then use azure.TTS(...)"},{"note":"Azure OpenAI (LLM, and OpenAI-powered STT/TTS) is handled by livekit-plugins-openai, not livekit-plugins-azure.","wrong":"from livekit.plugins import azure\n# ... then use azure.LLM()","symbol":"LLM","correct":"from livekit.plugins import openai\n# ... then use openai.responses.LLM.with_azure(...)"}],"quickstart":{"code":"import os\nfrom livekit.agents import AgentSession, JobContext\nfrom livekit.plugins import azure\n\nasync def my_azure_agent(ctx: JobContext):\n    # Ensure AZURE_SPEECH_KEY and AZURE_SPEECH_REGION are set in your environment\n    # e.g., via a .env file or directly as environment variables.\n    speech_key = os.environ.get('AZURE_SPEECH_KEY', '')\n    speech_region = os.environ.get('AZURE_SPEECH_REGION', '')\n\n    if not speech_key or not speech_region:\n        print(\"Error: AZURE_SPEECH_KEY and AZURE_SPEECH_REGION environment variables must be set.\")\n        return\n\n    session = AgentSession(\n        ctx,\n        stt=azure.STT(\n            speech_key=speech_key,\n            speech_region=speech_region\n        ),\n        tts=azure.TTS(\n            speech_key=speech_key,\n            speech_region=speech_region,\n            voice=\"en-US-JennyNeural\" # Specify a voice for TTS\n        )\n        # You would typically add an LLM (e.g., from livekit.plugins.openai) here\n        # llm=openai.responses.LLM.with_azure(...) \n    )\n\n    print(\"LiveKit Agent session initialized with Azure Speech STT and TTS.\")\n    # Example: Make the agent say something immediately\n    # await session.easy_reply(\"Hello, I am an AI agent powered by Azure Speech.\")\n    # This is where your agent's main logic would run\n    # await session.run()\n","lang":"python","description":"This quickstart demonstrates how to initialize a LiveKit Agent session using Azure Speech for both Speech-to-Text (STT) and Text-to-Speech (TTS). It requires setting `AZURE_SPEECH_KEY` and `AZURE_SPEECH_REGION` environment variables for authentication."},"warnings":[{"fix":"To disable preemptive generation, pass `preemptive_generation=False` to your `AgentSession` constructor. `session = AgentSession(ctx, preemptive_generation=False, ...)` [cite: 0 (from prompt)]","message":"LiveKit Agents v1.5.0 introduced 'preemptive generation' enabled by default for LLMs and TTS. This can impact latency expectations and resource usage across all agents, including those using Azure plugins. If not desired, it needs to be explicitly disabled during AgentSession initialization.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Use `from livekit.plugins import azure` for Azure Speech STT/TTS. Use `from livekit.plugins import openai` (and methods like `with_azure()`) for Azure OpenAI LLM, STT, or TTS.","message":"There is a common confusion between `livekit-plugins-azure` and `livekit-plugins-openai`. `livekit-plugins-azure` is for native Azure Speech STT/TTS services. Azure OpenAI (for LLM interactions, or OpenAI-powered STT/TTS endpoints hosted on Azure) requires `livekit-plugins-openai` configured with Azure-specific parameters.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure `AZURE_SPEECH_KEY` and `AZURE_SPEECH_REGION` are correctly set as environment variables or passed directly to the `azure.STT` and `azure.TTS` constructors. If using `speech_auth_token`, it must be supplied explicitly.","message":"Azure Speech authentication primarily relies on `AZURE_SPEECH_KEY` and `AZURE_SPEECH_REGION` environment variables. While `speech_auth_token` can be used, it's typically ephemeral and must be passed programmatically as an argument, not via environment variables.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify that the `AZURE_SPEECH_KEY` environment variable is set correctly and that the key is valid and active in your Azure portal. Also, ensure the key matches the specified region.","cause":"The provided Azure Speech Key (AZURE_SPEECH_KEY) is missing, invalid, or expired.","error":"azure.core.exceptions.ClientAuthenticationError: Authentication failed."},{"fix":"Ensure that either `speech_host` is provided, or both `speech_key` and `speech_region` are provided (via environment variables or directly as arguments), or both `speech_auth_token` and `speech_region` are provided.","cause":"The `azure.STT` or `azure.TTS` constructor did not receive sufficient authentication or endpoint information.","error":"ValueError: Missing one of: speech_host, (speech_key and speech_region), or (speech_auth_token and speech_region)"},{"fix":"For Azure OpenAI services (including LLMs or OpenAI-powered STT/TTS endpoints on Azure), you must import from `livekit.plugins.openai` and use its Azure-specific methods (e.g., `openai.responses.LLM.with_azure()`, `openai.STT.with_azure()`, `openai.TTS.with_azure()`).","cause":"Attempting to instantiate an LLM (or use OpenAI-specific STT/TTS) through the `livekit.plugins.azure` package, which only supports Azure Speech services.","error":"AttributeError: module 'livekit.plugins.azure' has no attribute 'LLM'"}]}