0

Groq Provider

Groq Provider explains the cloud layer of MTPX with practical guidance for building inspectable, tool-using agents.

Gr
Groq Provider
Chapter 033ProvidersCloudIndex
01Orientation

Groq Provider belongs to the providers track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how groq provider affects a real MTPX agent before you wire it into an application.

  • What groq provider owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
from mtp import Agent
from mtp.providers import Groq

agent = Agent.MTPAgent(
    provider=Groq(model="llama-3.3-70b-versatile"),
    tools=tools,
)
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

Groq provides ultra-fast cloud inference using their custom LPU hardware. Best for low-latency agent workflows with OpenAI-compatible tool schemas.

Install

bashpip install "mtpx[groq]"

Or install the SDK directly:

bashpip install groq

API Key Setup

  1. Install dotenv support:
bash   pip install python-dotenv

Or with the MTP extra:

bash   pip install "mtpx[dotenv]"
  1. Create a .env file in your project root:
text   GROQ_API_KEY=gsk_your_key_here
  1. Load it in your code before creating the provider:
python   from mtp import Agent

   Agent.load_dotenv_if_available()  # reads .env file

Get a free API key at console.groq.com.

Option 2: System environment variable

bash# Linux/macOS
export GROQ_API_KEY="gsk_..."

# Windows PowerShell
$env:GROQ_API_KEY="gsk_..."

Quick Start

pythonfrom mtp import Agent
from mtp.providers import Groq

Agent.load_dotenv_if_available()  # loads GROQ_API_KEY from .env

provider = Groq(model="llama-3.3-70b-versatile")
tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools)

reply = agent.run_loop("What is 25 * 4 + 10?")
print(reply)

Parameters

ParameterTypeDefaultDescription
modelstr"llama-3.3-70b-versatile"Groq model ID
api_keystr | NoneNoneAPI key (falls back to GROQ_API_KEY env var)
system_promptstr | NoneNoneSystem prompt prepended to all requests
temperaturefloat0.0Sampling temperature (0.0 = deterministic)
tool_choicestr | dict"auto"Tool selection strategy: "auto", "none", "required", or specific tool
parallel_tool_callsboolTrueAllow model to call multiple tools in parallel
encourage_batch_tool_callsboolTrueInject system hint to batch independent tool calls
strict_dependency_modeboolFalseEnable $ref based dependency tracking between tool calls
include_reasoningbool | NoneNoneInclude reasoning in response (for supported models)
reasoning_formatstr | NoneNoneFormat for reasoning output
reasoning_effortstr | NoneNoneReasoning effort level
stream_include_usageboolTrueInclude token usage in streaming responses
clientAny | NoneNonePre-configured groq.Groq client instance

Capabilities

CapabilityValue
Tool callingYes
Parallel tool callsYes (configurable)
Input modalitiestext, image
StreamingYes
Usage metricsRich
Reasoning metadataYes
Native asyncNo (uses thread fallback)
  • llama-3.3-70b-versatile — Best balance of speed and tool calling (default)
  • llama-3.1-8b-instant — Fastest, good for simple tasks
  • mixtral-8x7b-32768 — Large context window
  • gemma2-9b-it — Lightweight option

Full Example with Streaming

pythonfrom mtp import Agent
from mtp.providers import Groq

Agent.load_dotenv_if_available()

provider = Groq(
    model="llama-3.3-70b-versatile",
    temperature=0.0,
    parallel_tool_calls=True,
    encourage_batch_tool_calls=True,
    strict_dependency_mode=True,
)

tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools, debug_mode=True)

# Streaming events
for event in agent.run_loop_events(
    "Calculate (25 * 4) + 10",
    max_rounds=3,
    stream_final=True,
):
    print(event)

Source

src/mtp/providers/groq_provider.py

01

Read

Understand where Groq Provider sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docLM Studio Provider