PHPackages                             aisdk/groq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aisdk/groq

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aisdk/groq
==========

Official Groq provider for the PHP AI SDK.

v0.8.0(1mo ago)020↓50%MITPHPPHP ^8.3CI passing

Since Jun 30Pushed 4w agoCompare

[ Source](https://github.com/phpaisdk/groq)[ Packagist](https://packagist.org/packages/aisdk/groq)[ Docs](https://github.com/phpaisdk/groq)[ RSS](/packages/aisdk-groq/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (14)Versions (12)Used By (0)

aisdk/groq
==========

[](#aisdkgroq)

[![GitHub Workflow Status](https://camo.githubusercontent.com/7c7e090a4e334b854ce94bd8c9504ad35f04094967fb28d1424a0b796e5a1a20/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706870616973646b2f67726f712f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://github.com/phpaisdk/groq/actions)[![Total Downloads](https://camo.githubusercontent.com/d153e38ffa651f9c0a7ccfb7f0e18fe5ecd8cc11e54ffeef29af4b5c3b13ce93/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616973646b2f67726f71)](https://packagist.org/packages/aisdk/groq)[![Latest Version](https://camo.githubusercontent.com/52f9bf2033209ce60e4328c11222bf86257c7a4599bf8c5252de0d6e33a0f8c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616973646b2f67726f71)](https://packagist.org/packages/aisdk/groq)[![License](https://camo.githubusercontent.com/33522348481d8a7778994f91c0660df40778e92a5888135716e238903bbf73d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616973646b2f67726f71)](https://packagist.org/packages/aisdk/groq)[![Why PHP in 2026](https://camo.githubusercontent.com/d2b9305e630caf7daae4ca023de39ece0b885c37461629d42961533f00868b76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5768795f5048502d696e5f323032362d3741383645383f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d313831383162)](https://whyphp.dev)

---

Official Groq provider for the PHP AI SDK. Uses the shared OpenAI-compatible wire adapter.

Installation
------------

[](#installation)

```
composer require aisdk/groq
```

Basic Usage
-----------

[](#basic-usage)

```
use AiSdk\Generate;
use AiSdk\Groq;

$result = Generate::text()
    ->model(Groq::model('llama-3.3-70b-versatile'))
    ->instructions('Write short, clear answers.')
    ->prompt('Explain closures in PHP.')
    ->run();

echo $result->text;
```

Default model shorthand:

```
Generate::model(Groq::model('llama-3.3-70b-versatile'));

$result = Generate::text('Explain closures in PHP.')->run();
```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

VariableDescriptionDefault`GROQ_API_KEY`API key for authenticationRequired`GROQ_BASE_URL`Base URL for API requests`https://api.groq.com/openai/v1`### Programmatic Configuration

[](#programmatic-configuration)

```
$provider = Groq::create([
    'apiKey' => 'gsk-...',
    'baseUrl' => 'https://api.groq.com/openai/v1',
    'headers' => ['X-Custom-Header' => 'value'],
]);
```

Supported Capabilities
----------------------

[](#supported-capabilities)

CapabilitySupportText generationNativeStreamingNativeTool callingNativeStructured outputAdapted (`json_object` + instruction); exact native support can be declared at runtimeSpeech generationNativeTranscriptionNativeEmbeddingsNativeText inputNativeImage inputSupported by the adapter; the selected model is validated by GroqStreaming
---------

[](#streaming)

```
use AiSdk\Generate;
use AiSdk\Groq;

$stream = Generate::text('Tell me a story.')
    ->model(Groq::model('llama-3.3-70b-versatile'))
    ->stream();

foreach ($stream->chunks() as $chunk) {
    echo $chunk;
}

$result = $stream->run();
```

Embeddings
----------

[](#embeddings)

```
use AiSdk\Generate;
use AiSdk\Groq;

$result = Generate::embedding(['Search query', 'Document text'])
    ->model(Groq::model('nomic-embed-text-v1_5'))
    ->providerOptions('groq', ['user' => 'user-123'])
    ->run();

$queryVector = $result->embeddings[0]->vector;
$documentVector = $result->embeddings[1]->vector;
```

Groq's embedding request schema does not expose a dimensions field, so this adapter rejects the portable `dimensions()` option before sending a request.

Speech Generation
-----------------

[](#speech-generation)

```
use AiSdk\Generate;
use AiSdk\Groq;

$result = Generate::speech()
    ->model(Groq::model('canopylabs/orpheus-v1-english'))
    ->input('Welcome to Orpheus text-to-speech. [cheerful] This is expressive Groq audio generation.')
    ->voice('austin')
    ->format('wav')
    ->run();

$result->output->save(__DIR__.'/orpheus.wav');
```

Transcription
-------------

[](#transcription)

```
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Groq;

$result = Generate::transcription(Content::audio(__DIR__.'/meeting.mp3'))
    ->model(Groq::model('whisper-large-v3-turbo'))
    ->run();

echo $result->output->text;
```

Groq transcription also accepts an HTTP audio URL through `Content::audio('https://...')`.

Structured Output
-----------------

[](#structured-output)

Without an exact runtime capability override, the provider adapter degrades `json_schema` to `json_object` with an injected JSON instruction:

```
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Schema;

$result = Generate::text()
    ->model(Groq::model('llama-3.3-70b-versatile'))
    ->prompt('Extract the city and country from: Lahore, Pakistan.')
    ->output(Schema::object(
        name: 'address',
        properties: [
            Schema::string(name: 'city')->required(),
            Schema::string(name: 'country')->required(),
        ],
    ))
    ->run();
```

Models with native `json_schema` support (`openai/gpt-oss-20b`, `openai/gpt-oss-120b`, `moonshotai/kimi*`) use the native format directly.

Tools
-----

[](#tools)

```
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Schema;
use AiSdk\Tool;

$weather = Tool::make('weather', 'Get current weather')
    ->input(Schema::string(name: 'city')->required())
    ->run(fn (string $city): string => "Sunny in {$city}");

$result = Generate::text()
    ->model(Groq::model('llama-3.3-70b-versatile'))
    ->prompt('What is the weather in Lahore?')
    ->tool($weather)
    ->run();
```

Model IDs and Capabilities
--------------------------

[](#model-ids-and-capabilities)

Groq model IDs pass through unchanged and do not need to be registered. The package does not ship a model inventory; the Groq API remains the authority on whether a particular model accepts a requested feature.

Capabilities describe what the Groq adapter can serialize. The Groq API returns a normalized SDK exception if the selected model or requested feature is rejected.

Provider-Specific Options
-------------------------

[](#provider-specific-options)

Raw provider options can be passed as an escape hatch:

```
$result = Generate::text('Hello')
    ->model(Groq::model('llama-3.3-70b-versatile'))
    ->providerOptions('groq', [
        'raw' => ['top_k' => 40],
    ])
    ->run();
```

Testing
-------

[](#testing)

```
composer test
```

Documentation
-------------

[](#documentation)

- [PHP AI SDK documentation](https://phpaisdk.com/docs)
- [Groq documentation](https://phpaisdk.com/docs/groq)

Community
---------

[](#community)

- [Contributing](https://github.com/phpaisdk/.github/blob/main/CONTRIBUTING.md)
- [Support](https://github.com/phpaisdk/.github/blob/main/SUPPORT.md)
- For private security reports, email .

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance94

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

11

Last Release

31d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef29d1962da41e7526023f215cf844494e209b2fd163742084cb919a3b508021?d=identicon)[aisdk](/maintainers/aisdk)

---

Top Contributors

[![RanaMoizHaider](https://avatars.githubusercontent.com/u/58527494?v=4)](https://github.com/RanaMoizHaider "RanaMoizHaider (16 commits)")

---

Tags

aillmgroqopenai-compatibleaisdk

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aisdk-groq/health.svg)

```
[![Health](https://phpackages.com/badges/aisdk-groq/health.svg)](https://phpackages.com/packages/aisdk-groq)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
