Skip to main content

Provider-specific Swarmauri import package for Groq OpenAI-compatible chat, tool use, vision-language, streaming, and audio transcription workflows.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_llm_groq Discord

Swarmauri Groq LLM

swarmauri_llm_groq provides provider-specific Groq imports for Swarmauri applications that need fast OpenAI-compatible inference. The package exports chat, tool-calling, vision, and audio adapters while keeping their runtime implementations aligned with swarmauri_standard.

Groq's public API documentation describes an OpenAI-compatible base URL at https://api.groq.com/openai/v1, with endpoints for chat completions, audio transcriptions, and audio translations. This package maps those API surfaces into Swarmauri components:

  • GroqModel for chat completions, streaming, JSON responses, and batch helper workflows.
  • GroqToolModel for function/tool calling through Swarmauri Toolkit instances.
  • GroqVisionModel for vision-language chat completion payloads.
  • GroqAIAudio for transcription and translation with Groq-hosted Whisper models.

Why Use This Package?

  • Keep Groq-specific model dependencies explicit while preserving common Swarmauri conversation and toolkit patterns.
  • Use Groq's low-latency OpenAI-compatible chat completions without rewriting application code around raw HTTP payloads.
  • Add tool calling, vision-language prompts, or speech-to-text workflows from one provider package.
  • Swap between Groq and other Swarmauri LLM provider packages while retaining familiar predict, stream, apredict, astream, batch, and abatch workflows.

FAQ

What does swarmauri_llm_groq install?

It installs provider package entry points for GroqModel, GroqToolModel, GroqVisionModel, and GroqAIAudio.

Which Groq endpoints does it call?

The chat, tool, and vision adapters post to https://api.groq.com/openai/v1/chat/completions. The audio adapter uses https://api.groq.com/openai/v1/audio/transcriptions and https://api.groq.com/openai/v1/audio/translations.

Does it support tool calling?

Yes. GroqToolModel converts Swarmauri toolkit schemas to Groq-compatible tool definitions, sends them with chat completions, executes returned tool calls, and can perform a follow-up model call with tool results.

Does it support vision?

Yes. GroqVisionModel accepts Swarmauri message content that can include structured content lists for OpenAI-compatible vision chat payloads. The runtime also emits a deprecation warning that new projects should review the newer Swarmauri VLM imports when available.

Does audio streaming work?

No. GroqAIAudio supports file-based transcription and translation through predict, apredict, batch, and abatch. Its stream and astream methods raise NotImplementedError.

Features

  • GroqModel for synchronous, asynchronous, streaming, JSON, and batch chat completion workflows.
  • GroqToolModel for Groq tool use with Swarmauri Toolkit schemas.
  • GroqVisionModel for OpenAI-compatible vision-language chat payloads.
  • GroqAIAudio for Whisper transcription and translation tasks.
  • Usage metadata support where Groq chat responses include usage data.
  • Model discovery through Groq's OpenAI-compatible models endpoint for chat.
  • Compatibility with Python 3.10, 3.11, 3.12, 3.13, and 3.14.

Installation

uv add swarmauri_llm_groq
pip install swarmauri_llm_groq

Prerequisites

Create a Groq API key in the Groq console and pass it to the model constructor as api_key=.... Package live tests are skipped unless provider credentials are available in the environment.

Usage

from swarmauri_llm_groq import GroqModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation()
conversation.add_message(HumanMessage(content="Write a one-sentence release note."))

model = GroqModel(api_key="GROQ_API_KEY")
result = model.predict(conversation=conversation, max_tokens=120)

print(result.get_last().content)

Streaming Chat Completion

from swarmauri_llm_groq import GroqModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation()
conversation.add_message(HumanMessage(content="List three build pipeline risks."))

model = GroqModel(api_key="GROQ_API_KEY")

for token in model.stream(conversation=conversation):
    print(token, end="")

Tool Calling

from swarmauri_llm_groq import GroqToolModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
from swarmauri_standard.toolkits.Toolkit import Toolkit

conversation = Conversation()
conversation.add_message(HumanMessage(content="Use a tool if one is relevant."))

toolkit = Toolkit()
model = GroqToolModel(api_key="GROQ_API_KEY")
result = model.predict(conversation=conversation, toolkit=toolkit)

print(result.get_last().content)

Audio Transcription

from swarmauri_llm_groq import GroqAIAudio

audio = GroqAIAudio(api_key="GROQ_API_KEY")
text = audio.predict("meeting.wav", task="transcription")

print(text)

Vision-Language Prompt

from swarmauri_llm_groq import GroqVisionModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation()
conversation.add_message(
    HumanMessage(
        content=[
            {"type": "text", "text": "Describe the image."},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.png"}},
        ]
    )
)

model = GroqVisionModel(api_key="GROQ_API_KEY")
result = model.predict(conversation=conversation)

print(result.get_last().content)

Related Packages

Foundational Swarmauri Packages

Provider Documentation

Best Practices

  • Store Groq API keys in environment variables or a secrets manager.
  • Confirm model availability against Groq's current model catalog before production deployment.
  • Use GroqToolModel only when tools are needed; plain chat requests are simpler with GroqModel.
  • Use GroqAIAudio for file-based transcription and translation, not streaming audio.
  • Prefer newer Swarmauri VLM and STT imports for new projects when available.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_llm_groq-0.11.0.dev1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_llm_groq-0.11.0.dev1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_llm_groq-0.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_llm_groq-0.11.0.dev1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_llm_groq-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 6c5c916d20ab1d7dfa83ef8d1ce071f3e7426110867ce494b574b4bfa8b050f8
MD5 39b4b6bc7ec0192483050e7c66697faa
BLAKE2b-256 b405f39e4e1a9bebe37f43b5f9500e0c5a4df1a2c091ea05d7f58951c9974f80

See more details on using hashes here.

File details

Details for the file swarmauri_llm_groq-0.11.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_llm_groq-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_llm_groq-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4716d7cda5952870a300e21567296e0ed047d5943530169f264525cc26107dd
MD5 a1cdfd5c83b52ab53a18f425562a9526
BLAKE2b-256 57de2a36c1b2bcc54aa2740b9042dcd2fafc5bbf74ac0af91ca44a42b5be46b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page