承接 aisdk/google-agent-platform 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aisdk/google-agent-platform

Composer 安装命令:

composer require aisdk/google-agent-platform

包简介

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

README 文档

README

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

Installation

composer require aisdk/google-agent-platform

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;

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 = Generate::image('A clean product photograph')
    ->model(GoogleAgentPlatform::image('google/gemini-3.1-flash-image'))
    ->aspectRatio('16:9')
    ->run();

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

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

Streaming

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

Configuration

Variable Description
GOOGLE_VERTEX_PROJECT Google Cloud project id (required unless baseUrl set)
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 is powered by the official google/auth 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

composer test

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固