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 supports multimodal image input for Groq’s Llama 4 family of models. You can mix text and image parts inside a single user message by composing Content::text() and Content::image() values together, then wrapping them in Message::user(). The rest of the generation API stays identical to a standard text request — the SDK handles the encoding and routing transparently.

Supported Models

Only the two Llama 4 model patterns hosted on Groq support image input. All other Groq models will raise a CapabilityNotSupportedException if you attempt to pass image content.
Model PatternNotes
meta-llama/llama-4-scout*Matches all Scout variants, e.g. meta-llama/llama-4-scout-17b-16e-instruct
meta-llama/llama-4-maverick*Matches all Maverick variants, e.g. meta-llama/llama-4-maverick-17b-128e-instruct

Checking Image Input Support

Before sending an image, you can verify that a given model ID supports Capability::ImageInput:
Check image input support
use AiSdk\Capability;
use AiSdk\Groq;

// Llama 4 Scout — supported
$scout = Groq::model('meta-llama/llama-4-scout-17b-16e-instruct')
    ->supports(Capability::ImageInput);          // true

// Llama 4 Maverick — supported
$maverick = Groq::model('meta-llama/llama-4-maverick-17b-128e-instruct')
    ->supports(Capability::ImageInput);          // true

// Older Llama model — not supported
$llama3 = Groq::model('llama-3.1-8b-instant')
    ->supports(Capability::ImageInput);          // false
->supports() is a convenience wrapper around ->capability()->isSupported(). Use ->capability(Capability::ImageInput) if you need the full CapabilitySupport object including the strategy string.

Sending an Image

1
Build the multimodal message
2
Combine a text part and an image URL part inside Message::user() using an array of Content values.
3
use AiSdk\Content;
use AiSdk\Message;

$message = Message::user([
    Content::text('What is shown in this image?'),
    Content::image('https://example.com/photo.jpg'),
]);
4
Pass the message to the generate builder
5
Use ->messages() (or the equivalent prompt builder) to include your composed message, and select a Llama 4 model.
6
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Message;

$result = Generate::text()
    ->model(Groq::model('meta-llama/llama-4-scout-17b-16e-instruct'))
    ->messages([
        Message::user([
            Content::text('Describe what you see in this image.'),
            Content::image('https://example.com/photo.jpg'),
        ]),
    ])
    ->run();
7
Read the response
8
The model’s description is available on $result->text, exactly as with a standard text generation.
9
echo $result->text;
// "The image shows a mountain range at sunset with snow-capped peaks..."

Complete Example

Image input — complete example
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Message;

$result = Generate::text()
    ->model(Groq::model('meta-llama/llama-4-maverick-17b-128e-instruct'))
    ->messages([
        Message::user([
            Content::text('Read the text visible in this image and return it verbatim.'),
            Content::image('https://example.com/sign.jpg'),
        ]),
    ])
    ->run();

echo $result->text;

What Happens with Unsupported Models

If you pass Content::image() to a model that does not declare image_input capability, the SDK raises a CapabilityNotSupportedException before the request leaves the process — no API call is made.
Unsupported model raises an exception
use AiSdk\Content;
use AiSdk\Exceptions\CapabilityNotSupportedException;
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Message;

try {
    $result = Generate::text()
        ->model(Groq::model('llama-3.1-8b-instant'))   // no image_input
        ->messages([
            Message::user([
                Content::text('What is in this image?'),
                Content::image('https://example.com/photo.jpg'),
            ]),
        ])
        ->run();
} catch (CapabilityNotSupportedException $e) {
    echo $e->getMessage();
    // "Model llama-3.1-8b-instant does not support the ImageInput capability."
}
Always select a meta-llama/llama-4-scout* or meta-llama/llama-4-maverick* model when sending image content. Using any other Groq model will throw a CapabilityNotSupportedException at runtime.

Combining Images with Instructions

You can pair image messages with a system instruction using ->instructions() to steer how the model interprets or reports on the image.
Image input with system instructions
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Groq;
use AiSdk\Message;

$result = Generate::text()
    ->model(Groq::model('meta-llama/llama-4-scout-17b-16e-instruct'))
    ->instructions('You are a precise visual analyst. Respond in bullet points.')
    ->messages([
        Message::user([
            Content::text('Identify every distinct object in this photograph.'),
            Content::image('https://example.com/scene.jpg'),
        ]),
    ])
    ->run();

echo $result->text;
For best results, keep image URLs publicly accessible and served over HTTPS. The Groq API fetches the image at inference time, so slow or authenticated URLs will cause request failures or timeouts.

Build docs developers (and LLMs) love