Module livekit.plugins.groq

Sub-modules

livekit.plugins.groq.log
livekit.plugins.groq.models
livekit.plugins.groq.services
livekit.plugins.groq.tts
livekit.plugins.groq.version

Classes

class LLM (*,
model: str | Literal['llama3-8b-8192', 'llama3-70b-8192', 'llama-guard-3-8b', 'llama-3.1-8b-instant', 'llama-3.3-70b-versatile'] = 'llama-3.3-70b-versatile',
api_key: str | None = None,
user: str | None = None,
temperature: float | None = None,
parallel_tool_calls: bool | None = None,
tool_choice: ToolChoice | Literal['auto', 'required', 'none'] = 'auto',
max_tokens: int | None = None,
base_url: str | None = 'https://api.groq.com/openai/v1',
client: openai.AsyncOpenAI | None = None)
Expand source code
class LLM(OpenAILLM):
    def __init__(
        self,
        *,
        model: str | LLMModels = "llama-3.3-70b-versatile",
        api_key: str | None = None,
        user: str | None = None,
        temperature: float | None = None,
        parallel_tool_calls: bool | None = None,
        tool_choice: Union[ToolChoice, Literal["auto", "required", "none"]] = "auto",
        max_tokens: int | None = None,
        base_url: str | None = "https://api.groq.com/openai/v1",
        client: openai.AsyncClient | None = None,
    ):
        """
        Create a new instance of Groq LLM.

        ``api_key`` must be set to your Groq API key, either using the argument or by setting
        the ``GROQ_API_KEY`` environmental variable.
        """
        super().__init__(
            model=model,
            api_key=_get_api_key(api_key),
            base_url=base_url,
            client=client,
            user=user,
            temperature=temperature,
            parallel_tool_calls=parallel_tool_calls,
            tool_choice=tool_choice,
            max_tokens=max_tokens,
        )

Helper class that provides a standard way to create an ABC using inheritance.

Create a new instance of Groq LLM.

api_key must be set to your Groq API key, either using the argument or by setting the GROQ_API_KEY environmental variable.

Ancestors

Inherited members

class STT (*,
model: Literal['whisper-large-v3', 'whisper-large-v3-turbo', 'distil-whisper-large-v3-en'] | str = 'whisper-large-v3-turbo',
api_key: str | None = None,
base_url: str | None = 'https://api.groq.com/openai/v1',
client: openai.AsyncOpenAI | None = None,
language: str = 'en',
prompt: str | None = None,
detect_language: bool = False)
Expand source code
class STT(OpenAISTT):
    def __init__(
        self,
        *,
        model: STTModels | str = "whisper-large-v3-turbo",
        api_key: str | None = None,
        base_url: str | None = "https://api.groq.com/openai/v1",
        client: openai.AsyncClient | None = None,
        language: str = "en",
        prompt: str | None = None,
        detect_language: bool = False,
    ):
        """
        Create a new instance of Groq STT.

        ``api_key`` must be set to your Groq API key, either using the argument or by setting
        the ``GROQ_API_KEY`` environmental variable.
        """
        super().__init__(
            model=model,
            api_key=_get_api_key(api_key),
            base_url=base_url,
            client=client,
            language=language,
            detect_language=detect_language,
            prompt=prompt,
            use_realtime=False,
        )

Helper class that provides a standard way to create an ABC using inheritance.

Create a new instance of Groq STT.

api_key must be set to your Groq API key, either using the argument or by setting the GROQ_API_KEY environmental variable.

Ancestors

Inherited members

class TTS (*,
base_url: str | None = None,
model: TTSModels | str = 'playai-tts',
voice: TTSVoices | str = 'Arista-PlayAI',
api_key: str | None = None,
http_session: aiohttp.ClientSession | None = None)
Expand source code
class TTS(tts.TTS):
    def __init__(
        self,
        *,
        base_url: str | None = None,
        model: TTSModels | str = "playai-tts",
        voice: TTSVoices | str = "Arista-PlayAI",
        api_key: str | None = None,
        http_session: aiohttp.ClientSession | None = None,
    ) -> None:
        """
        Create a new instance of Groq TTS.

        if `api_key` is not provided, it will be read from the ``GROQ_API_KEY``
        environmental variable.

        Args:
            model (SpeechModels | str, optional): Model to use. Default is "playai-tts".
            voice (SpeechVoices | str, optional): Voice to use. Default is "Autumn-PlayAI".
            api_key (str | None, optional): API key to use. Default is None.
        """

        super().__init__(
            capabilities=tts.TTSCapabilities(
                streaming=False,
            ),
            sample_rate=SAMPLE_RATE,
            num_channels=1,
        )

        self._session = http_session

        if not base_url:
            base_url = DEFAULT_BASE_URL

        if not api_key:
            api_key = os.getenv("GROQ_API_KEY")
            if not api_key:
                raise ValueError("GROQ_API_KEY is not set")

        self._opts = _TTSOptions(
            model=model,
            voice=voice,
            api_key=api_key,
            base_url=base_url,
        )

    def _ensure_session(self) -> aiohttp.ClientSession:
        if not self._session:
            self._session = utils.http_context.http_session()

        return self._session

    def update_options(
        self,
        *,
        model: TTSModels | None = None,
        voice: TTSVoices | None = None,
    ) -> None:
        """
        Update the TTS options.

        Args:
            model (SpeechModels | str, optional): Model to use. Default is None.
            voice (SpeechVoices | str, optional): Voice to use. Default is None.
        """
        if model:
            self._opts.model = model
        if voice:
            self._opts.voice = voice

    def synthesize(
        self,
        text: str,
        *,
        conn_options: Optional[APIConnectOptions] = None,
        segment_id: str | None = None,
    ) -> "ChunkedStream":
        return ChunkedStream(
            tts=self,
            input_text=text,
            conn_options=conn_options,
            opts=self._opts,
            session=self._ensure_session(),
            segment_id=segment_id,
        )

Helper class that provides a standard way to create an ABC using inheritance.

Create a new instance of Groq TTS.

if api_key is not provided, it will be read from the GROQ_API_KEY environmental variable.

Args

model : SpeechModels | str, optional
Model to use. Default is "playai-tts".
voice : SpeechVoices | str, optional
Voice to use. Default is "Autumn-PlayAI".
api_key : str | None, optional
API key to use. Default is None.

Ancestors

Methods

def synthesize(self,
text: str,
*,
conn_options: Optional[APIConnectOptions] = None,
segment_id: str | None = None) ‑> ChunkedStream
Expand source code
def synthesize(
    self,
    text: str,
    *,
    conn_options: Optional[APIConnectOptions] = None,
    segment_id: str | None = None,
) -> "ChunkedStream":
    return ChunkedStream(
        tts=self,
        input_text=text,
        conn_options=conn_options,
        opts=self._opts,
        session=self._ensure_session(),
        segment_id=segment_id,
    )
def update_options(self, *, model: TTSModels | None = None, voice: TTSVoices | None = None) ‑> None
Expand source code
def update_options(
    self,
    *,
    model: TTSModels | None = None,
    voice: TTSVoices | None = None,
) -> None:
    """
    Update the TTS options.

    Args:
        model (SpeechModels | str, optional): Model to use. Default is None.
        voice (SpeechVoices | str, optional): Voice to use. Default is None.
    """
    if model:
        self._opts.model = model
    if voice:
        self._opts.voice = voice

Update the TTS options.

Args

model : SpeechModels | str, optional
Model to use. Default is None.
voice : SpeechVoices | str, optional
Voice to use. Default is None.

Inherited members