Skip to main content
Prism Vertex allows you to use multiple providers simultaneously, each with its own configuration. This enables you to use different authentication methods, regions, or models for different parts of your application.

Shared configuration

All providers share a single vertex configuration block by default:
config/prism.php
return [
    'providers' => [
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => env('VERTEX_LOCATION', 'us-central1'),
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
    ],
];
With this configuration, all provider constants use the same settings:
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;

// All use the same project_id, location, and credentials
$gemini = Prism::text()
    ->using(Vertex::Gemini, 'gemini-2.5-flash')
    ->withPrompt('Hello')
    ->asText();

$claude = Prism::text()
    ->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
    ->withPrompt('Hello')
    ->asText();

$mistral = Prism::text()
    ->using(Vertex::Mistral, 'mistral-small-2503')
    ->withPrompt('Hello')
    ->asText();

Per-provider configuration

You can override the shared configuration for specific providers by adding per-provider config blocks:
config/prism.php
return [
    'providers' => [
        // Shared configuration
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => env('VERTEX_LOCATION', 'us-central1'),
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
        
        // Override for Anthropic (different region)
        'vertex-anthropic' => [
            'location' => 'europe-west1',
        ],
        
        // Override for Gemini (API key instead of credentials)
        'vertex-gemini' => [
            'api_key' => env('VERTEX_GEMINI_API_KEY'),
        ],
    ],
];
Now each provider uses its own configuration:
Uses europe-west1 region:
$response = Prism::text()
    ->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
    ->withPrompt('Hello')
    ->asText();
Configuration:
  • project_id: from shared config
  • location: europe-west1 (overridden)
  • credentials: from shared config

Provider configuration keys

Each provider constant maps to a configuration key:
Provider ConstantConfig Key
Vertex::Geminivertex-gemini
Vertex::Anthropicvertex-anthropic
Vertex::Mistralvertex-mistral
Vertex::Metavertex-meta
Vertex::DeepSeekvertex-deepseek
Vertex::AI21vertex-ai21
Vertex::Kimivertex-kimi
Vertex::MiniMaxvertex-minimax
Vertex::OpenAIvertex-openai
Vertex::Qwenvertex-qwen
Vertex::ZAIvertex-zai

Common use cases

Here are common scenarios where per-provider configuration is useful:

Different regions for different providers

Use different regions for latency optimization:
config/prism.php
return [
    'providers' => [
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => 'us-central1', // Default for most providers
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
        
        // Use Europe region for Anthropic
        'vertex-anthropic' => [
            'location' => 'europe-west1',
        ],
        
        // Use Asia region for Gemini
        'vertex-gemini' => [
            'location' => 'asia-northeast1',
        ],
    ],
];

Different authentication methods

Use API key for Gemini (Express mode) and service account for others:
config/prism.php
return [
    'providers' => [
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => env('VERTEX_LOCATION'),
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
        
        // Use API key for Gemini (Express mode)
        'vertex-gemini' => [
            'api_key' => env('VERTEX_GEMINI_API_KEY'),
            // Omit project_id and location for Express mode
        ],
    ],
];
Express mode only supports Google Gemini models. Partner models require Standard mode with project_id and location.

Different projects for billing separation

Use different GCP projects for cost tracking:
config/prism.php
return [
    'providers' => [
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => env('VERTEX_LOCATION'),
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
        
        // Use separate project for production Gemini workloads
        'vertex-gemini' => [
            'project_id'  => env('VERTEX_GEMINI_PROJECT_ID'),
            'credentials' => env('VERTEX_GEMINI_CREDENTIALS'),
        ],
        
        // Use separate project for experimental Claude workloads
        'vertex-anthropic' => [
            'project_id'  => env('VERTEX_ANTHROPIC_PROJECT_ID'),
            'credentials' => env('VERTEX_ANTHROPIC_CREDENTIALS'),
        ],
    ],
];

Configuration merging

Per-provider configurations are merged with the shared configuration:
1
Start with shared config
2
The shared vertex configuration provides defaults:
3
'vertex' => [
    'project_id'  => 'my-project',
    'location'    => 'us-central1',
    'credentials' => '/path/to/service-account.json',
]
4
Override specific values
5
Per-provider config overrides only the specified values:
6
'vertex-anthropic' => [
    'location' => 'europe-west1',
]
7
Result is merged
8
The final configuration for Vertex::Anthropic is:
9
[
    'project_id'  => 'my-project',           // from shared
    'location'    => 'europe-west1',         // overridden
    'credentials' => '/path/to/service-account.json', // from shared
]

Complete example

Here’s a complete example using multiple providers with different configurations:
config/prism.php
return [
    'providers' => [
        // Shared configuration for most providers
        'vertex' => [
            'project_id'  => env('VERTEX_PROJECT_ID'),
            'location'    => 'us-central1',
            'credentials' => env('VERTEX_CREDENTIALS'),
        ],
        
        // Gemini uses Express mode with API key
        'vertex-gemini' => [
            'api_key' => env('VERTEX_GEMINI_API_KEY'),
        ],
        
        // Anthropic uses Europe region
        'vertex-anthropic' => [
            'location' => 'europe-west1',
        ],
        
        // Meta uses separate project
        'vertex-meta' => [
            'project_id'  => env('VERTEX_META_PROJECT_ID'),
            'credentials' => env('VERTEX_META_CREDENTIALS'),
        ],
    ],
];
Usage:
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;

// Uses Express mode (API key only)
$gemini = Prism::text()
    ->using(Vertex::Gemini, 'gemini-2.5-flash')
    ->withPrompt('Hello')
    ->asText();

// Uses europe-west1 region
$claude = Prism::text()
    ->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
    ->withPrompt('Hello')
    ->asText();

// Uses separate GCP project
$llama = Prism::text()
    ->using(Vertex::Meta, 'llama-4-scout-17b-16e-instruct-maas')
    ->withPrompt('Hello')
    ->asText();

// Uses shared config (us-central1, main project)
$mistral = Prism::text()
    ->using(Vertex::Mistral, 'mistral-small-2503')
    ->withPrompt('Hello')
    ->asText();

Runtime provider options

You can also override configuration at runtime using withProviderOptions():
use Prism\Vertex\Enums\VertexSchema;

$response = Prism::text()
    ->using(Vertex::Gemini, 'gemini-2.5-flash')
    ->withProviderOptions([
        'apiSchema' => VertexSchema::Anthropic, // Override API schema
        'jsonModeMessage' => 'Custom JSON instruction', // Custom JSON message
    ])
    ->withPrompt('Hello')
    ->asText();
Runtime options override both shared and per-provider configuration. Use with caution.

Available configuration options

All configuration options that can be set:
OptionTypeDescription
project_idstringGCP project ID
locationstringGCP region (e.g., us-central1)
credentialsstringPath to service account JSON file
api_keystringAPI key for authentication
apiSchemaVertexSchemaForce specific API schema (Gemini, Anthropic, or OpenAI)

Best practices

1
Start with shared configuration
2
Define common settings in the shared vertex config:
3
'vertex' => [
    'project_id'  => env('VERTEX_PROJECT_ID'),
    'location'    => env('VERTEX_LOCATION', 'us-central1'),
    'credentials' => env('VERTEX_CREDENTIALS'),
],
4
Override only what’s different
5
Only specify values that differ from the shared config:
6
// Good: Override only location
'vertex-anthropic' => [
    'location' => 'europe-west1',
],

// Bad: Repeat all values
'vertex-anthropic' => [
    'project_id'  => env('VERTEX_PROJECT_ID'),
    'location'    => 'europe-west1',
    'credentials' => env('VERTEX_CREDENTIALS'),
],
7
Use environment variables
8
Store sensitive values in environment variables:
9
VERTEX_PROJECT_ID=my-project
VERTEX_LOCATION=us-central1
VERTEX_CREDENTIALS=/path/to/service-account.json

VERTEX_GEMINI_API_KEY=your-api-key
VERTEX_ANTHROPIC_PROJECT_ID=anthropic-project
10
Document your configuration
11
Add comments explaining why you’re using different settings:
12
'vertex' => [
    'project_id'  => env('VERTEX_PROJECT_ID'),
    'location'    => 'us-central1', // Main US region for lowest latency
    'credentials' => env('VERTEX_CREDENTIALS'),
],

// Use Europe region for GDPR compliance
'vertex-anthropic' => [
    'location' => 'europe-west1',
],

// Use Express mode for development
'vertex-gemini' => [
    'api_key' => env('VERTEX_GEMINI_API_KEY'),
],

Next steps

Text generation

Generate text responses using Vertex AI

Structured output

Generate JSON responses with schema validation

Embeddings

Create text embeddings for semantic search

Configuration

View complete configuration reference

Build docs developers (and LLMs) love