1. Go to this page and download the library: Download rmh/vertex library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rmh / vertex example snippets
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => env('VERTEX_LOCATION', 'us-central1'),
// Auth - choose one (or omit both to use Application Default Credentials):
'credentials' => env('VERTEX_CREDENTIALS'), // path to service-account.json
// 'api_key' => env('VERTEX_API_KEY'),
],
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
// Google Gemini
$response = Prism::text()
->using(Vertex::Gemini, 'gemini-2.5-flash')
->withPrompt('Explain quantum computing in simple terms')
->asText();
echo $response->text;
// Anthropic Claude on Vertex AI
$response = Prism::text()
->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
->withPrompt('Explain quantum computing in simple terms')
->asText();
// Meta Llama on Vertex AI
$response = Prism::text()
->using(Vertex::Meta, 'llama-4-scout-17b-16e-instruct-maas')
->withPrompt('Explain quantum computing in simple terms')
->asText();
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;
use Prism\Prism\Schema\ArraySchema;
$schema = new ObjectSchema(
name: 'languages',
description: 'Top programming languages',
properties: [
new ArraySchema(
'languages',
'List of programming languages',
items: new ObjectSchema(
name: 'language',
description: 'Programming language details',
properties: [
new StringSchema('name', 'The language name'),
new StringSchema('popularity', 'Popularity description'),
]
)
)
]
);
$response = Prism::structured()
->using(Vertex::Gemini, 'gemini-2.5-flash')
->withSchema($schema)
->withPrompt('List the top 3 programming languages')
->asStructured();
$data = $response->structured;
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
$response = Prism::embeddings()
->using(Vertex::Gemini, 'text-embedding-005')
->fromInput('The sky is blue')
->asEmbeddings();
$embeddings = $response->embeddings;