{"id":8284,"library":"livekit-plugins-groq","title":"LiveKit Groq Plugin","description":"livekit-plugins-groq is a Python plugin that enables LiveKit Agents to utilize Groq's high-speed inference for Large Language Models (LLM), Speech-to-Text (STT), and Text-to-Speech (TTS). It is actively maintained as part of the livekit-agents ecosystem, with releases generally aligning with the livekit-agents project, currently at version 1.5.4.","status":"active","version":"1.5.4","language":"en","source_language":"en","source_url":"https://github.com/livekit/agents","tags":["livekit","groq","llm","stt","tts","ai-agents","realtime-audio","voice-ai","inference"],"install":[{"cmd":"pip install livekit-plugins-groq","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core framework for building LiveKit AI agents, which this plugin extends.","package":"livekit-agents"}],"imports":[{"note":"The Groq plugin exposes LLM, STT, and TTS functionalities through the 'groq' module.","symbol":"groq","correct":"from livekit.plugins import groq"},{"note":"Access LLM directly from the groq plugin submodule. It can also be accessed via `groq.LLM` after importing `from livekit.plugins import groq`.","wrong":"from livekit.plugins import groq.LLM","symbol":"LLM","correct":"from livekit.plugins.groq import LLM"}],"quickstart":{"code":"import os\nfrom livekit.agents import AgentSession, JobContext, WorkerOptions\nfrom livekit.plugins import groq\n\n# Set your Groq API key (e.g., in a .env file or directly as an environment variable)\nos.environ['GROQ_API_KEY'] = os.environ.get('GROQ_API_KEY', 'your_groq_api_key_here')\n\nasync def entrypoint(ctx: JobContext):\n    session = AgentSession(\n        llm=groq.LLM(\n            model=\"llama3-8b-8192\", # or 'llama-3.3-70b-versatile'\n            temperature=0.7\n        ),\n        # Optionally add Groq STT and TTS\n        # stt=groq.STT(model=\"whisper-large-v3-turbo\"),\n        # tts=groq.TTS(model=\"playai-tts\", voice=\"Arista-PlayAI\"),\n        # ... other agent session configurations like vad, turn_handling\n    )\n\n    # In a real application, you'd handle participant events and process audio/text\n    # For a minimal quickstart, this demonstrates LLM initialization.\n    # For example:\n    # while True:\n    #     user_message = await session.stt.recognize_one_utterance()\n    #     if user_message:\n    #         reply_text = await session.llm.generate_reply(messages=[{'role': 'user', 'content': user_message.text}])\n    #         await session.tts.synthesize(reply_text)\n\n    print(\"Groq LLM initialized within AgentSession. Ensure GROQ_API_KEY is set.\")\n\n# Example of how you might run this (typically part of a larger LiveKit Agent server setup)\nif __name__ == \"__main__\":\n    # This part is illustrative; actual LiveKit Agent deployment uses AgentServer.start()\n    # You would normally run your agent via `python -m your_agent_file dev`\n    print(\"To run a full LiveKit Agent, please refer to the LiveKit Agents documentation.\")\n    print(\"Ensure GROQ_API_KEY is set in your environment or .env file.\")\n","lang":"python","description":"This quickstart demonstrates how to initialize a LiveKit Agent session using Groq as the Large Language Model (LLM) provider. It highlights the essential import and configuration steps, including setting the `GROQ_API_KEY` environment variable. Groq can also be configured for STT and TTS."},"warnings":[{"fix":"Set the `GROQ_API_KEY` environment variable in your system, `.env` file, or pass it directly as `api_key` argument to `groq.LLM`, `groq.STT`, or `groq.TTS`.","message":"The Groq plugin requires an API key for authentication. This key must be provided via the `GROQ_API_KEY` environment variable. Failing to set it will result in authentication errors when attempting to use Groq services.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If preemptive generation is not desired, it can be disabled during `AgentSession` initialization: `session = AgentSession(preemptive_generation=False, ...)`.","message":"Starting with livekit-agents 1.5.0, 'preemptive generation' for LLM and TTS is enabled by default. This feature starts inference before the user's turn fully ends to reduce latency but can lead to increased costs or unexpected behavior if not accounted for.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Always refer to the latest LiveKit Groq documentation or the Groq API documentation for a current list of supported TTS models. Ensure your `livekit-plugins-groq` version is up-to-date to benefit from fixes.","message":"LiveKit's Groq plugin provides support for specific Groq TTS models (e.g., `playai-tts`). Using deprecated or unsupported model names can lead to errors. An issue was logged in late 2025 regarding deprecated TTS models, which was addressed in subsequent updates.","severity":"gotcha","affected_versions":"<1.5.x"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you have installed the package using `pip install livekit-plugins-groq` and that your virtual environment is activated before running your script.","cause":"The `livekit-plugins-groq` package is either not installed, or the Python virtual environment where it's installed is not active.","error":"ImportError: cannot import name 'groq' from 'livekit.plugins'"},{"fix":"Set the `GROQ_API_KEY` environment variable (e.g., in a `.env` file loaded by `python-dotenv`) or provide the key when initializing `groq.LLM(api_key=\"YOUR_KEY\")`, `groq.STT(api_key=\"YOUR_KEY\")`, or `groq.TTS(api_key=\"YOUR_KEY\")`.","cause":"The Groq API key, essential for authentication, was not found in the environment variables and was not passed directly to the plugin's constructor.","error":"Groq API key not provided. Set GROQ_API_KEY environment variable or pass `api_key` in constructor."},{"fix":"Specify a valid `response_format` parameter in your `groq.TTS` configuration, choosing from `flac`, `mp3`, `mulaw`, `ogg`, or `wav`.","cause":"When using Groq TTS, an unsupported audio output format was requested, or the default format is no longer valid/supported by the Groq API.","error":"ValueError: response_format must be one of [flac mp3 mulaw ogg wav]"}]}