TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/groq/llms.txt
Use this file to discover all available pages before exploring further.
Groq facade (namespace AiSdk) is the primary entry point for the Groq provider package. It manages a lazily-created singleton GroqProvider instance so that most applications need only a single line of setup — or no setup at all when GROQ_API_KEY is present in the environment. All methods are static, making the facade convenient to call from anywhere in your codebase without dependency injection.
Methods
Groq::create()
Creates a new GroqProvider from a configuration array and registers it as the package-wide default. Any subsequent call to Groq::default() or Groq::model() will use this provider until Groq::reset() is called.
Creating a provider explicitly
An associative array of provider options. All keys are optional when the corresponding environment variable is set. Accepted keys:
The newly created
GroqProvider instance, which has also been set as the current default.Groq::default()
Returns the current default GroqProvider. If no provider has been created yet, it calls Groq::create() with an empty config array, which resolves credentials from environment variables.
Accessing the default provider
You rarely need to call
Groq::default() directly. Groq::model() calls it internally and is the more ergonomic option for most use cases.The existing default provider, or a freshly created one if none has been set.
Groq::model()
Resolves a text model by its Groq model ID using the default provider. This is the canonical way to obtain a TextModelInterface ready to be passed to Generate::text().
Resolving a model and generating text
The Groq model identifier, such as
'llama-3.3-70b-versatile', 'llama-4-scout-17b-16e-instruct', or any other model available on your Groq account. Unknown model IDs are allowed — the provider will surface the API error at call time.A
GroqTextModel instance implementing AiSdk\Contracts\TextModelInterface, ready for use with Generate::text().Groq::reset()
Clears the default provider singleton, setting it back to null. The next call to Groq::default() or Groq::model() will create a fresh provider.
Resetting between tests
Groq::registerModel()
Registers a custom model definition on the default provider’s model registry. Use this to add new or preview Groq models at runtime without waiting for a package release. The method is provided by the RegistersModels trait.
Two calling conventions are supported:
Terse form — pass a string model ID and a capability array:
Registering a model with the terse form
ModelDefinition object for fine-grained control over adapted capabilities and metadata:
Registering a model with a ModelDefinition
Either the string model ID (used with the
capabilities array) or a fully constructed ModelDefinition object.An array of
AiSdk\Capability enum cases describing what the model supports. Only used when $model is a string; ignored when a ModelDefinition is passed.