PHPackages                             rmh/vertex - 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. [API Development](/categories/api)
4. /
5. rmh/vertex

ActiveLibrary[API Development](/categories/api)

rmh/vertex
==========

A provider for Prism adding support for Google Vertex AI.

v1.1.0(4mo ago)3406—0%MITPHPPHP ^8.2CI failing

Since Feb 23Pushed 4mo agoCompare

[ Source](https://github.com/RanaMoizHaider/vertex)[ Packagist](https://packagist.org/packages/rmh/vertex)[ GitHub Sponsors](https://github.com/ranamoizhaider)[ RSS](/packages/rmh-vertex/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (34)Versions (3)Used By (0)

 [ ![Total Downloads](https://camo.githubusercontent.com/09267b2d6d53eed385ba9a61a520ecb1e4ae638bc67ebd4f6f5da5dedb4ac362/68747470733a2f2f706f7365722e707567782e6f72672f726d682f7665727465782f642f746f74616c2e737667) ](https://packagist.org/packages/rmh/vertex) [ ![Latest Stable Version](https://camo.githubusercontent.com/ddee4643b9b4185af6e798e41ba4f35fa12896faf2ee0f36589c45895982ea3a/68747470733a2f2f706f7365722e707567782e6f72672f726d682f7665727465782f762f737461626c652e737667) ](https://packagist.org/packages/rmh/vertex) [ ![License](https://camo.githubusercontent.com/a9b76610999b83ef785434ef7b76dd80a95cccd07e3c7b08c8d90963ab6f1d81/68747470733a2f2f706f7365722e707567782e6f72672f726d682f7665727465782f6c6963656e73652e737667) ](https://packagist.org/packages/rmh/vertex)

Prism Vertex
============

[](#prism-vertex)

A standalone Google Vertex AI provider for the [Prism PHP](https://github.com/prism-php/prism) framework. Access Google Gemini and partner model families through a single configuration and unified interface.

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

[](#installation)

```
composer require rmh/vertex
```

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

[](#configuration)

Add the following to your Prism configuration (`config/prism.php`):

### Standard mode (project + location required)

[](#standard-mode-project--location-required)

```
'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'),
],
```

### Express mode (API key only, Google models only)

[](#express-mode-api-key-only-google-models-only)

When `project_id` and `location` are omitted, the package automatically uses [Vertex AI Express Mode](https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode) endpoints:

```
'vertex' => [
    'api_key' => env('VERTEX_API_KEY'),
    // project_id and location omitted — triggers Express mode
],
```

Important

Express mode only supports Google Gemini models. Using partner model providers in Express mode will throw an exception.

Usage
-----

[](#usage)

Use the provider constants from `Prism\Vertex\Enums\Vertex` with the Prism facade:

### Text Generation

[](#text-generation)

```
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();
```

### Structured Output (JSON)

[](#structured-output-json)

```
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;
```

### Embeddings

[](#embeddings)

```
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;
```

### Streaming

[](#streaming)

Warning

Streaming is not yet supported. This feature is planned for a future release.

Supported Providers
-------------------

[](#supported-providers)

All providers share one `vertex` config block. The provider constant determines which API schema and publisher endpoint is used:

ConstantPublisherExample ModelsSchema`Vertex::Gemini``google``gemini-2.5-flash`, `text-embedding-005`Gemini`Vertex::Anthropic``anthropic``claude-3-5-sonnet@20241022`, `claude-3-5-haiku@20241022`Anthropic`Vertex::Mistral``mistralai``mistral-small-2503`, `codestral-2501`OpenAI`Vertex::Meta``meta``llama-4-scout-17b-16e-instruct-maas`OpenAI`Vertex::DeepSeek``deepseek``deepseek-v3-0324-maas`OpenAI`Vertex::AI21``ai21``jamba-1.5-mini@001`, `jamba-1.5-large@001`OpenAI`Vertex::Kimi``kimi``kimi-k2-0711-maas`OpenAI`Vertex::MiniMax``minimax``minimax-m1-40k-0709-maas`OpenAI`Vertex::OpenAI``openai``gpt-oss-4o-mini-maas`OpenAI`Vertex::Qwen``qwen``qwen2.5-72b-instruct-maas`OpenAI`Vertex::ZAI``zaiorg``glm-4-plus-maas`OpenAIAPI Schemas
-----------

[](#api-schemas)

Prism Vertex uses three API schemas to handle the different formats used by Vertex AI publishers:

SchemaTextStructuredEmbeddingsGeminiyesyesyesAnthropicyesyesnoOpenAIyesyesno- **Gemini** — Google's native `generateContent` / `predict` endpoints.
- **Anthropic** — Uses `:rawPredict` with the Anthropic Messages API format (`anthropic_version: vertex-2023-10-16`).
- **OpenAI** — Uses `:rawPredict` or `:chatCompletions` with OpenAI-compatible format for partner models (Mistral, Meta, DeepSeek, AI21, Kimi, MiniMax, OpenAI-OSS, Qwen, ZAI).

The provider constant automatically selects the correct schema. You can override it via `withProviderOptions()`:

```
use Prism\Vertex\Enums\VertexSchema;

$response = Prism::text()
    ->using(Vertex::Gemini, 'some-model')
    ->withProviderOptions(['apiSchema' => VertexSchema::Anthropic])
    ->withPrompt('Hello')
    ->asText();
```

Structured Output Details
-------------------------

[](#structured-output-details)

Each schema handles structured output differently:

- **Gemini** — Native structured output via `response_mime_type: application/json` and `response_schema`. The model is constrained to produce valid JSON matching your schema.
- **OpenAI** — Uses `response_format: { type: "json_object" }` combined with a schema instruction message. All MaaS partner models support this mode.
- **Anthropic** — No native JSON mode. A prompt is appended instructing the model to respond with JSON conforming to the provided schema.

You can override the schema instruction prompt for Anthropic and OpenAI schemas using `withProviderOptions()`:

```
Prism::structured()
    ->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
    ->withSchema($schema)
    ->withProviderOptions([
        'jsonModeMessage' => 'My custom JSON instruction message',
    ])
    ->withPrompt('My prompt')
    ->asStructured();
```

Authentication
--------------

[](#authentication)

### API Key

[](#api-key)

Set the `api_key` config option. The key is sent as a `?key=` query parameter on every request. This works for both Standard and Express modes.

### Service Account JSON file

[](#service-account-json-file)

Set the `credentials` config option to the path of your service account JSON key file. The package uses [`google/auth`](https://github.com/googleapis/google-auth-library-php) to obtain a Bearer token automatically.

### Application Default Credentials (ADC)

[](#application-default-credentials-adc)

When neither `credentials` nor `api_key` are set in Standard mode, the package automatically uses [Application Default Credentials](https://cloud.google.com/docs/authentication/external/set-up-adc). This is the recommended approach for code running on Google Cloud Platform, no credentials need to be configured at all.

ADC resolves credentials in this order:

1. `GOOGLE_APPLICATION_CREDENTIALS` environment variable (path to a JSON key file)
2. `gcloud auth application-default login` (local development)
3. Attached service account (GCE, GKE, Cloud Run, Cloud Functions, etc.)

```
'vertex' => [
    'project_id' => env('VERTEX_PROJECT_ID'),
    'location'   => env('VERTEX_LOCATION', 'us-central1'),
    // no api_key or credentials - ADC handles auth automatically
],
```

### Per-Provider Config Overrides

[](#per-provider-config-overrides)

All providers read from the shared `vertex` config. If you need different credentials for a specific provider, add a per-provider config block — it will override the shared config:

```
'vertex' => [
    'project_id'  => env('VERTEX_PROJECT_ID'),
    'location'    => env('VERTEX_LOCATION', 'us-central1'),
    'credentials' => env('VERTEX_CREDENTIALS'),
],

// Override for Anthropic only (e.g. different region)
'vertex-anthropic' => [
    'location' => 'europe-west1',
],
```

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12
- [prism-php/prism](https://github.com/prism-php/prism) &gt;= 0.99.7

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance78

Regular maintenance activity

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Total

2

Last Release

120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/892294ff938f797c91632aa8225eb83b27483ae1dc666185685fb06ae048784b?d=identicon)[rmh](/maintainers/rmh)

---

Top Contributors

[![RanaMoizHaider](https://avatars.githubusercontent.com/u/58527494?v=4)](https://github.com/RanaMoizHaider "RanaMoizHaider (4 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rmh-vertex/health.svg)

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

3.0k37.6M134](/packages/darkaonline-l5-swagger)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k14.2M63](/packages/knuckleswtf-scribe)[google/gax

Google API Core for PHP

267116.3M567](/packages/google-gax)[googleads/google-ads-php

Google Ads API client for PHP

3508.5M12](/packages/googleads-google-ads-php)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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