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

ActiveLibrary

aisdk/google-agent-platform
===========================

Official Google Cloud Agent Platform (Vertex AI) provider for the PHP AI SDK.

v0.8.0(1mo ago)19↓25%MITPHPPHP ^8.3CI passing

Since Jul 11Pushed 1mo agoCompare

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

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

aisdk/google-agent-platform
===========================

[](#aisdkgoogle-agent-platform)

[![GitHub Workflow Status](https://camo.githubusercontent.com/e5ee5d6f3907b063c66c54e15a90cd5a8cc3764de788539546a81a3c543e8247/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706870616973646b2f676f6f676c652d6167656e742d706c6174666f726d2f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://github.com/phpaisdk/google-agent-platform/actions)[![Total Downloads](https://camo.githubusercontent.com/688b3a7bec9a183d43a69b2443fb6bf377fd80bed1862f071193148b83719a9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616973646b2f676f6f676c652d6167656e742d706c6174666f726d)](https://packagist.org/packages/aisdk/google-agent-platform)[![Latest Version](https://camo.githubusercontent.com/492ba1f7592f245ee81ccda2146549c4c2942ed8c75fcb2f6bf554e38145e46a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616973646b2f676f6f676c652d6167656e742d706c6174666f726d)](https://packagist.org/packages/aisdk/google-agent-platform)[![License](https://camo.githubusercontent.com/55f63b7c83ff2941285f8a49e5af565959d8a146b05086533b6a9bd5524e9379/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616973646b2f676f6f676c652d6167656e742d706c6174666f726d)](https://packagist.org/packages/aisdk/google-agent-platform)[![Why PHP in 2026](https://camo.githubusercontent.com/d2b9305e630caf7daae4ca023de39ece0b885c37461629d42961533f00868b76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5768795f5048502d696e5f323032362d3741383645383f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d313831383162)](https://whyphp.dev)

---

Official Google Cloud Agent Platform provider for the framework-agnostic PHP AI SDK. It uses the OpenAI-compatible endpoint for text and transcription, and native publisher model endpoints for embeddings, image, and speech generation.

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

[](#installation)

```
composer require aisdk/google-agent-platform
```

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

[](#basic-usage)

```
use AiSdk\Generate;
use AiSdk\GoogleAgentPlatform;

$result = Generate::text()
    ->model(GoogleAgentPlatform::model('google/gemini-2.5-flash'))
    ->prompt('Explain closures in PHP.')
    ->run();

echo $result->text;
```

Embeddings
----------

[](#embeddings)

```
$embedding = Generate::embedding(['First document to index', 'Second document to index'])
    ->model(GoogleAgentPlatform::model('gemini-embedding-001'))
    ->dimensions(768)
    ->providerOptions('google-agent-platform', [
        'task_type' => 'RETRIEVAL_DOCUMENT',
        'autoTruncate' => false,
    ])
    ->run();

$vector = $embedding->output->vector;
```

The package sends one native publisher-model request per input, which supports the documented single-input limit of `gemini-embedding-001`. Provider options use Google's documented field names: `task_type`, `title`, `autoTruncate`, and `outputDimensionality`.

Publisher and routed model IDs pass through unchanged and do not need to be registered. This package does not ship a model inventory; the SDK performs internal adapter validation before Google Cloud validates support for the selected model, project, and location.

Image and speech generation
---------------------------

[](#image-and-speech-generation)

```
$image = Generate::image('A clean product photograph')
    ->model(GoogleAgentPlatform::model('google/gemini-3.1-flash-image'))
    ->aspectRatio('16:9')
    ->run();

$speech = Generate::speech('Welcome to the application.')
    ->model(GoogleAgentPlatform::model('google/gemini-3.1-flash-tts-preview'))
    ->voice('Kore')
    ->run();
```

Native embedding, image, and speech generation require `project`; a custom OpenAI-compatible `baseUrl` alone is not enough to construct the publisher model endpoint.

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

[](#transcription)

```
use AiSdk\Content;
use AiSdk\Generate;
use AiSdk\GoogleAgentPlatform;

$result = Generate::transcription(Content::audio(__DIR__.'/meeting.mp3'))
    ->model(GoogleAgentPlatform::model('google/gemini-2.5-flash'))
    ->run();

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

Transcription uses the routed multimodal model endpoint, so it follows the same authentication and model-id rules as text generation.

Live voice sessions
-------------------

[](#live-voice-sessions)

Install the optional transport package for a ready-made WebSocket connection:

```
composer require aisdk/transport
```

```
use AiSdk\GoogleAgentPlatform;
use AiSdk\Live;
use AiSdk\Live\AudioDelta;
use AiSdk\Live\TranscriptDelta;
use AiSdk\Transport;

$session = Live::voice()
    ->model(GoogleAgentPlatform::model('gemini-live-2.5-flash-native-audio'))
    ->instructions('You are a concise customer-support agent.')
    ->voice('Kore')
    ->language('en-US')
    ->connect(Transport::auto());

// Send 16 kHz mono PCM chunks while reading events concurrently.
$session->sendAudio($pcmBytes);

foreach ($session->events() as $event) {
    if ($event instanceof AudioDelta) {
        playAudio($event->bytes);
    }

    if ($event instanceof TranscriptDelta) {
        echo $event->delta;
    }
}
```

Core automatically runs registered tools that have handlers and sends the provider's required function response. Tool calls without a matching handler are emitted for manual handling.

Provider-only setup fields can be merged without adding them to core. For example, a previously received session-resumption handle can be supplied with:

```
->providerOptions('google-agent-platform', [
    'raw' => ['session_resumption' => ['handle' => $resumeHandle]],
])
```

Resumption updates and unknown native messages are preserved as `ProviderEvent`values.

Agent Platform Live sessions can emit input and output transcripts, but this package does not claim dedicated `Live::transcribe()` or `Live::translate()`implementations. Google Cloud Speech-to-Text streaming is a separate gRPC service, and Gemini Developer API Live Translate's `translationConfig` protocol is not documented for the Agent Platform endpoint.

### Core-only transport

[](#core-only-transport)

The provider is fully usable without `aisdk/transport`. Pass any application implementation of the core transport contracts:

```
$session = Live::voice()
    ->model(GoogleAgentPlatform::model('gemini-live-2.5-flash-native-audio'))
    ->connect($appWebSocketTransport);
```

See the [core custom-transport guide](https://github.com/phpaisdk/core#core-without-aisdktransport)for a complete implementation. The connection receives the current native v1 Agent Platform WebSocket endpoint and OAuth, ADC, or API-key headers prepared by this package.

Agent Platform's native Live WebSocket streams media directly. With the default server-side activity detection, speech boundaries are detected automatically and the protocol does not document a separate audio commit event. When turn detection is disabled, `commitAudio()` sends the documented manual activity-end signal. `clearAudio()` remains unsupported because the protocol has no input buffer. It also does not expose the client-secret, WebRTC, or SIP lifecycle implemented by providers that officially support those topologies.

Streaming
---------

[](#streaming)

```
foreach (Generate::text('Tell me a story.')->model(GoogleAgentPlatform::model('google/gemini-2.5-flash'))->stream()->chunks() as $chunk) {
    echo $chunk;
}
```

Video Generation
----------------

[](#video-generation)

```
$result = Generate::video('A cinematic ocean scene')
    ->model(GoogleAgentPlatform::model('veo-3.1-generate-001'))
    ->aspectRatio('16:9')
    ->resolution('1920x1080')
    ->run(timeout: 600);
```

Veo operations use the native publisher-model endpoint and can return inline video bytes or a Cloud Storage URI.

Reasoning and multimodal input
------------------------------

[](#reasoning-and-multimodal-input)

Portable reasoning maps to Google's native thinking configuration. Effort levels become `thinking_level`, while token budgets become `thinking_budget`:

```
$result = Generate::text('Explain the tradeoff.')
    ->model(GoogleAgentPlatform::model('google/gemini-3.1-pro-preview'))
    ->reasoning(\AiSdk\Reasoning::effort('medium'))
    ->run();
```

Google-specific `extra_body.google.thinking_config` provider options take precedence when supplied explicitly. Text requests also accept documented image and audio inputs; audio formats are serialized using Google's MIME-style values such as `audio/wav`.

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

[](#configuration)

VariableDescription`GOOGLE_CLOUD_PROJECT` / `GOOGLE_VERTEX_PROJECT`Google Cloud project id (required unless `baseUrl` set)`GOOGLE_CLOUD_LOCATION` / `GOOGLE_VERTEX_LOCATION`Region (defaults to `global`)`GOOGLE_VERTEX_ACCESS_TOKEN`Static OAuth access token`GOOGLE_VERTEX_CREDENTIALS_PATH`Path to a service account JSON key`GOOGLE_APPLICATION_CREDENTIALS`Standard ADC service-account path`GOOGLE_VERTEX_API_KEY`API key (express mode)Authentication
--------------

[](#authentication)

Authentication is powered by the official [`google/auth`](https://github.com/googleapis/google-auth-library-php)library and supports the full set of Google credential sources:

- **Application Default Credentials (ADC)** — used automatically when no explicit credential is given: `GOOGLE_APPLICATION_CREDENTIALS`, `gcloud`user credentials, GCE/GKE metadata server, and workload identity federation.
- **Service account** — JSON key as an array or file path (OAuth token exchange handled for you).
- **Static OAuth access token** — bring your own (e.g. `gcloud auth print-access-token`).
- **API key** — express mode via the `x-goog-api-key` header.

```
// Application Default Credentials (nothing to configure)
GoogleAgentPlatform::create(['project' => 'my-project', 'location' => 'us-central1']);

// Service account file
GoogleAgentPlatform::create([
    'project' => 'my-project',
    'location' => 'us-central1',
    'credentialsPath' => '/path/to/service-account.json',
]);

// Service account array
GoogleAgentPlatform::create([
    'project' => 'my-project',
    'credentials' => $decodedServiceAccountJson,
]);

// Static access token
GoogleAgentPlatform::create(['project' => 'my-project', 'accessToken' => 'ya29....']);
```

Testing
-------

[](#testing)

```
composer test
```

The default suite uses protocol fixtures and conformance checks. Credentialed Live network verification is separate from the default test run.

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

[](#documentation)

- [PHP AI SDK documentation](https://phpaisdk.com/docs)
- [Google Agent Platform documentation](https://phpaisdk.com/docs/google-agent-platform)

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

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Total

6

Last Release

47d 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 (11 commits)")

---

Tags

aillmvertexopenai-compatibleaisdkgoogle-agent-platformgemini-enterprise

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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