LiveKit AssemblyAI Plugin

1.5.4 · active · verified Thu Apr 16

LiveKit AssemblyAI Plugin is an Agent Framework plugin for integrating AssemblyAI's Speech-to-Text (STT) capabilities into LiveKit AI Agents. It enables real-time transcription for conversational AI applications. The library is actively maintained with frequent releases, often in sync with the core `livekit-agents` library, and is currently at version 1.5.4.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the AssemblyAI STT plugin. It requires the `ASSEMBLYAI_API_KEY` environment variable to be set. For a complete voice agent, the `assemblyai.STT` instance would be passed to the `AgentSession` constructor.

import os
from livekit.agents import AgentSession, JobContext
from livekit.plugins import assemblyai
from livekit.agents.voice import VoiceAgent
from dotenv import load_dotenv

load_dotenv()

class MyAssemblyAIAgent(VoiceAgent):
    def __init__(self, ctx: JobContext):
        super().__init__(ctx)
        self.stt = assemblyai.STT(
            api_key=os.environ.get('ASSEMBLYAI_API_KEY', '')
        )

    async def start(self):
        # Example: Using AssemblyAI STT directly (not in a full agent pipeline)
        # For a full agent, you'd pass self.stt to AgentSession's stt parameter.
        print("AssemblyAI STT initialized. API Key status: ", "Set" if self.stt.api_key else "Not Set")

if __name__ == "__main__":
    # In a real application, you'd run the agent via LiveKit's infrastructure.
    # This is a minimal example to show STT initialization.
    if not os.environ.get('ASSEMBLYAI_API_KEY'):
        print("Warning: ASSEMBLYAI_API_KEY environment variable is not set. STT may fail.")
    # You can instantiate the STT directly for testing or use it within a full AgentSession
    my_stt_instance = assemblyai.STT(api_key=os.environ.get('ASSEMBLYAI_API_KEY', ''))
    print(f"AssemblyAI STT configured with API key: {'Yes' if my_stt_instance.api_key else 'No'}")

view raw JSON →