Skip to content

pydantic_ai.models.groq

Setup

For details on how to set up authentication with this model, see model configuration for Groq.

GroqModelSettings

Bases: ModelSettings

Settings used for a Groq model request.

Attributes

groq_reasoning_format

The format of the reasoning output.

See the Groq docs for more details.

Type: Literal[‘hidden’, ‘raw’, ‘parsed’]

GroqModel

Bases: Model

A model that uses the Groq API.

Internally, this uses the Groq Python client to interact with the API.

Apart from __init__, all methods are private or match those of the base class.

Attributes

model_name

The model name.

Type: GroqModelName

system

The model provider.

Type: str

Methods

__init__
def __init__(
    model_name: GroqModelName,
    provider: Literal['groq', 'gateway'] | Provider[AsyncGroq] = 'groq',
    profile: ModelProfileSpec | None = None,
    settings: ModelSettings | None = None,
)

Initialize a Groq model.

Parameters

model_name : GroqModelName

The name of the Groq model to use. List of model names available here.

provider : Literal[‘groq’, ‘gateway’] | Provider[AsyncGroq] Default: 'groq'

The provider to use for authentication and API access. Can be either the string ‘groq’ or an instance of Provider[AsyncGroq]. If not provided, a new provider will be created using the other parameters.

profile : ModelProfileSpec | None Default: None

The model profile to use. Defaults to a profile picked by the provider based on the model name.

settings : ModelSettings | None Default: None

Model-specific settings that will be used as defaults for this model.

supported_builtin_tools

@classmethod

def supported_builtin_tools(cls) -> frozenset[type[AbstractBuiltinTool]]

Return the set of builtin tool types this model can handle.

Returns

frozenset[type[AbstractBuiltinTool]]

GroqStreamedResponse

Bases: StreamedResponse

Implementation of StreamedResponse for Groq models.

Attributes

model_name

Get the model name of the response.

Type: GroqModelName

provider_name

Get the provider name.

Type: str

provider_url

Get the provider base URL.

Type: str

timestamp

Get the timestamp of the response.

Type: datetime

ProductionGroqModelNames

Production Groq models from https://console.groq.com/docs/models#production-models.

Default: Literal['llama-3.1-8b-instant', 'llama-3.3-70b-versatile', 'meta-llama/llama-guard-4-12b', 'openai/gpt-oss-120b', 'openai/gpt-oss-20b', 'whisper-large-v3', 'whisper-large-v3-turbo']

PreviewGroqModelNames

Preview Groq models from https://console.groq.com/docs/models#preview-models.

Default: Literal['meta-llama/llama-4-maverick-17b-128e-instruct', 'meta-llama/llama-4-scout-17b-16e-instruct', 'meta-llama/llama-prompt-guard-2-22m', 'meta-llama/llama-prompt-guard-2-86m', 'moonshotai/kimi-k2-instruct-0905', 'openai/gpt-oss-safeguard-20b', 'playai-tts', 'playai-tts-arabic', 'qwen/qwen-3-32b']

GroqModelName

Possible Groq model names.

Since Groq supports a variety of models and the list changes frequencly, we explicitly list the named models as of 2025-03-31 but allow any name in the type hints.

See https://console.groq.com/docs/models for an up to date date list of models and more details.

Default: str | ProductionGroqModelNames | PreviewGroqModelNames