Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/google/llms.txt

Use this file to discover all available pages before exploring further.

Gemini models support multimodal input — text, images, audio, and documents can all be included in a single request. The aisdk/google provider inspects each Content object in your message and maps it to the correct Gemini content type, handling both URL references and base64-encoded inline data transparently.

Content types

The table below shows how PHP AI SDK content type constants map to the type field sent in the Gemini request body:
TypeSDK constantGemini type field
ImageContent::TYPE_IMAGEimage
AudioContent::TYPE_AUDIOaudio
Document/FileContent::TYPE_FILEdocument
Text content (Content::TYPE_TEXT) is always mapped to { "type": "text" } and can be freely mixed with media parts in the same message.

Image from URL

Pass an image URL and the provider will build a { type: 'image', uri: '...', mime_type: '...' } part:
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Google;
use AiSdk\Message;

Google::create(['apiKey' => env('GOOGLE_GENERATIVE_AI_API_KEY')]);

$result = Generate::text()
    ->model(Google::model('gemini-3.5-flash'))
    ->messages([
        Message::user([
            Content::text('What is shown in this image?'),
            Content::imageUrl('https://example.com/photo.jpg', 'image/jpeg'),
        ]),
    ])
    ->run();

echo $result->text;
The resulting request part sent to the API looks like:
{
  "type": "image",
  "uri": "https://example.com/photo.jpg",
  "mime_type": "image/jpeg"
}

Image from base64 / inline data

When you have raw image bytes (from a file upload, in-memory buffer, or data URI), pass them via Content::imageBase64() or Content::imageData(). The provider encodes them as inline_data:
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Google;
use AiSdk\Message;

$imageBytes = file_get_contents('/path/to/screenshot.png');

$result = Generate::text()
    ->model(Google::model('gemini-3.5-flash'))
    ->messages([
        Message::user([
            Content::text('Describe any errors visible in this screenshot.'),
            Content::imageData($imageBytes, 'image/png'),
        ]),
    ])
    ->run();

echo $result->text;
The resulting request part sent to the API looks like:
{
  "type": "image",
  "inline_data": {
    "mime_type": "image/png",
    "data": "<base64-encoded bytes>"
  }
}

Audio input

The same pattern applies to audio. Use Content::audioUrl() for a hosted file or Content::audioData() for inline bytes. The Gemini type field becomes "audio":
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Google;
use AiSdk\Message;

$result = Generate::text()
    ->model(Google::model('gemini-3.5-flash'))
    ->messages([
        Message::user([
            Content::text('Transcribe this audio clip.'),
            Content::audioUrl('https://example.com/clip.mp3', 'audio/mpeg'),
        ]),
    ])
    ->run();

echo $result->text;

File / document input

PDF and other document formats are supported via Content::TYPE_FILE. The Gemini type field becomes "document":
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\Google;
use AiSdk\Message;

$pdfBytes = file_get_contents('/path/to/contract.pdf');

$result = Generate::text()
    ->model(Google::model('gemini-3.5-flash'))
    ->messages([
        Message::user([
            Content::text('Summarise the key clauses in this contract.'),
            Content::fileData($pdfBytes, 'application/pdf'),
        ]),
    ])
    ->run();

echo $result->text;
You can also pass a publicly accessible URL for documents:
Content::fileUrl('https://example.com/report.pdf', 'application/pdf')
Multimodal input is supported by models that advertise the image_input, audio_input, and file_input capabilities. Based on the current model catalogue, all gemini-1.5*, gemini-2.0*, gemini-2.5*, and gemini-3* text models include all three capabilities. Image-generation variants (e.g. gemini-3.1-flash-image) support image_input only.
If you pass a media Content object that has neither a URL nor base64/raw bytes attached, the request builder will throw an InvalidArgumentException with the message:
Google media input requires URL, raw, base64, or data URI content.
Make sure every non-text Content object carries a source before calling ->run().

Build docs developers (and LLMs) love