Skip to main content

Documentation 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.

The PHP AI SDK Groq Provider (aisdk/groq) is the official integration between the PHP AI SDK and Groq’s inference API. It lets you call any Groq-hosted model — Llama 4, Kimi, OpenAI GPT OSS, and more — using the same fluent PHP interface as every other provider in the ecosystem.

Quickstart

Install the package and run your first text generation in under five minutes.

Configuration

Set your API key, base URL, and custom headers via env vars or code.

Guides

Deep-dive into streaming, tool calling, structured output, and image input.

API Reference

Full reference for the Groq facade, provider, options, and text model classes.

What you can build

The Groq provider surfaces every capability that Groq’s API supports and automatically adapts the ones that differ per model:

Text Generation

Generate completions from any Groq-hosted model with a single fluent call.

Streaming

Receive tokens as they are produced for real-time UIs and CLI tools.

Structured Output

Return typed PHP arrays matching a JSON schema — with automatic fallback for models that lack native support.

Tool Calling

Let models invoke PHP callables and receive their results in a single round-trip.

Image Input

Pass images alongside text prompts to multimodal Llama 4 models.

Custom Models

Register new or preview models at runtime without waiting for a package update.

Quick example

quickstart.php
use AiSdk\Generate;
use AiSdk\Groq;

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

echo $result->text;
1

Install via Composer

composer require aisdk/groq
2

Set your API key

export GROQ_API_KEY=gsk-...
3

Generate your first response

Pass a prompt and call ->run() — the result object contains the generated text and token usage.
Follow the Quickstart for a complete walkthrough including streaming and structured output examples.

Build docs developers (and LLMs) love