Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
GroqLLM
Groq LLM plugin using Groq’s OpenAI-compatible inference API. Provides ultra-low-latency inference over Groq’s LPU hardware, supporting Llama 3.x models, OpenAI GPT-OSS variants, and Groq Compound agentic systems. Includes optional reasoning control for supported models.Constructor
Groq API key. Falls back to the
GROQ_API_KEY environment variable when None.Groq model ID. Known values (
GroqLLMModel): "llama-3.3-70b-versatile" (default, 131k context, ~280 tok/s), "llama-3.1-8b-instant" (~560 tok/s), "openai/gpt-oss-20b", "openai/gpt-oss-120b" (~500 tok/s), "groq/compound", "groq/compound-mini". Any string is accepted for forward compatibility.Sampling temperature. Higher values produce more varied output. Groq converts
0 to 1e-8 internally. Default: 0.7.Maximum tokens to generate in the response. Default:
1024.Nucleus sampling probability cutoff (0.0–1.0).
None uses the model default.Penalises tokens by how often they appear, reducing repetition.
None uses the model default.Penalises tokens that have already appeared, encouraging topic diversity.
None uses the model default.Random seed for reproducible outputs when supported.
None uses non-deterministic sampling.Stop sequence; generation halts when this string is produced.
None disables early stopping.End-user identifier forwarded to the API for monitoring and abuse detection.
None omits the field.Controls function-calling behaviour. Typical values:
"auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name. None uses the model default.When
True, the model may emit multiple tool calls in a single turn. None uses the model default.response_format
Structured output format descriptor (e.g.
{"type": "json_object"}). None returns plain text.Reasoning token budget hint for supported reasoning models. For GPT-OSS models:
"low", "medium", or "high". None omits the parameter.Controls how the model’s reasoning chain is surfaced.
"parsed" places it in a dedicated message field; "raw" embeds it inside <think> tags in the content; "hidden" returns only the final answer. Mutually exclusive with include_reasoning. None omits the parameter.Groq service tier.
"on_demand" (default when omitted), "flex" (higher throughput, best-effort), "performance" (enterprise, lowest latency), or "auto" (platform selects the best available tier). None uses the Groq API default ("on_demand").aclose
cancel_current_generation
chat
The conversation history to send to the model.
Optional tool definitions the model may call.
Optional conversational graph guiding the exchange.
LLMResponse: Response chunks produced as the model generates output.
emit
The event to emit.
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.