PHPackages                             aisdk/google - 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/google

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

aisdk/google
============

Official Google Gemini provider for the PHP AI SDK.

v0.3.0(2d ago)020—0%MITPHP ^8.3

Since Jul 7Compare

[ Source](https://github.com/phpaisdk/google)[ Packagist](https://packagist.org/packages/aisdk/google)[ Docs](https://github.com/phpaisdk/google)[ RSS](/packages/aisdk-google/feed)WikiDiscussions Synced today

READMEChangelog (6)Dependencies (6)Versions (7)Used By (0)

aisdk/google
============

[](#aisdkgoogle)

Official Google Gemini provider for the PHP AI SDK.

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

[](#installation)

```
composer require aisdk/google
```

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

[](#basic-usage)

```
use AiSdk\Generate;
use AiSdk\Google;

$result = Generate::text()
    ->model(Google::model('gemini-3.5-flash'))
    ->instructions('Write short, clear answers.')
    ->prompt('Explain closures in PHP.')
    ->run();

echo $result->text;
```

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

[](#configuration)

VariableDescriptionDefault`GOOGLE_GENERATIVE_AI_API_KEY`API key for authenticationRequired`GEMINI_API_KEY`Fallback API key variableRequired`GOOGLE_GENERATIVE_AI_BASE_URL`Base URL for API requests`https://generativelanguage.googleapis.com/v1beta````
Google::create([
    'apiKey' => '...',
    'baseUrl' => 'https://generativelanguage.googleapis.com/v1beta',
]);
```

Streaming
---------

[](#streaming)

```
$stream = Generate::text('Tell me a story.')
    ->model(Google::model('gemini-3.5-flash'))
    ->stream();

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

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

Image Generation
----------------

[](#image-generation)

```
use AiSdk\Generate;
use AiSdk\Google;

$result = Generate::image()
    ->model(Google::image('gemini-3.1-flash-image'))
    ->prompt('A clean app icon for a PHP AI SDK')
    ->aspectRatio('1:1')
    ->run();

$result->output->save(__DIR__.'/icon.png');
```

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

[](#speech-generation)

```
use AiSdk\Generate;
use AiSdk\Google;

$result = Generate::speech()
    ->model(Google::speech('gemini-3.1-flash-tts-preview'))
    ->input('Say cheerfully: Have a wonderful day!')
    ->voice('Kore')
    ->run();

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

Google speech generation uses Gemini Interactions API audio responses. You can pass native speech configuration through provider options:

```
$result = Generate::speech('Read this as a short dialogue.')
    ->model(Google::speech('gemini-3.1-flash-tts-preview'))
    ->providerOptions('google', [
        'generation_config' => [
            'speech_config' => [
                ['speaker' => 'Joe', 'voice' => 'Kore'],
                ['speaker' => 'Jane', 'voice' => 'Puck'],
            ],
        ],
    ])
    ->run();
```

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

[](#provider-specific-options)

```
$result = Generate::text('Hello')
    ->model(Google::model('gemini-3.5-flash'))
    ->providerOptions('google', [
        'raw' => [
            'generation_config' => ['temperature' => 0.2],
            'store' => false,
        ],
    ])
    ->run();
```

Testing
-------

[](#testing)

```
composer test
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance99

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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 ~0 days

Total

6

Last Release

2d ago

### Community

Maintainers

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

---

Tags

googleaiGeminillmaisdk

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

318123.0k1](/packages/cognesy-instructor-php)[wordpress/ai-provider-for-google

AI Provider for Google for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.

171.2k](/packages/wordpress-ai-provider-for-google)[wordpress/ai-provider-for-anthropic

AI Provider for Anthropic for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.

191.0k](/packages/wordpress-ai-provider-for-anthropic)

PHPackages © 2026

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