By default, all Vertex AI providers share the same configuration from the vertex block in your config/prism.php. However, you can override configuration for specific providers by adding per-provider config blocks.
How provider overrides work
When you use a specific provider constant (like Vertex::Anthropic or Vertex::Mistral), Prism checks for a provider-specific config block that matches the provider key. If found, it merges those settings with the base vertex config, with the provider-specific settings taking precedence.
Provider keys
Each provider constant has a corresponding config key:
| Constant | Config Key |
|---|
Vertex::Gemini | vertex-gemini |
Vertex::Anthropic | vertex-anthropic |
Vertex::Mistral | vertex-mistral |
Vertex::Meta | vertex-meta |
Vertex::DeepSeek | vertex-deepseek |
Vertex::AI21 | vertex-ai21 |
Vertex::Kimi | vertex-kimi |
Vertex::MiniMax | vertex-minimax |
Vertex::OpenAI | vertex-openai |
Vertex::Qwen | vertex-qwen |
Vertex::ZAI | vertex-zai |
Common override scenarios
Different regions for different providers
You might want to use different Vertex AI regions for different providers (for example, to take advantage of regional model availability or lower latency):
// config/prism.php
'providers' => [
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => env('VERTEX_LOCATION', 'us-central1'),
'credentials' => env('VERTEX_CREDENTIALS'),
],
// Use Europe region for Anthropic models
'vertex-anthropic' => [
'location' => 'europe-west1',
],
// Use Asia region for Gemini models
'vertex-gemini' => [
'location' => 'asia-northeast1',
],
],
Now when you use Vertex::Anthropic, it will use europe-west1, and Vertex::Gemini will use asia-northeast1. All other providers will use the default us-central1.
Separate credentials per provider
You can use different service accounts or API keys for different providers:
// config/prism.php
'providers' => [
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => 'us-central1',
'credentials' => env('VERTEX_CREDENTIALS'),
],
// Use different service account for Anthropic
'vertex-anthropic' => [
'credentials' => env('VERTEX_ANTHROPIC_CREDENTIALS'),
],
// Use API key for Gemini (Express mode)
'vertex-gemini' => [
'api_key' => env('VERTEX_GEMINI_API_KEY'),
'project_id' => null,
'location' => null,
],
],
When you set project_id and location to null for a specific provider, that provider will use Express mode even if the base vertex config has Standard mode settings.
Different projects per provider
You can route different providers to different Google Cloud projects:
// config/prism.php
'providers' => [
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => 'us-central1',
'credentials' => env('VERTEX_CREDENTIALS'),
],
// Use different project for Mistral models
'vertex-mistral' => [
'project_id' => env('VERTEX_MISTRAL_PROJECT_ID'),
'credentials' => env('VERTEX_MISTRAL_CREDENTIALS'),
],
],
Override precedence
The merge logic works as follows:
- Start with the base
vertex config
- Merge in the provider-specific config (e.g.,
vertex-anthropic)
- Provider-specific values override base values
Example:
'providers' => [
'vertex' => [
'project_id' => 'my-project',
'location' => 'us-central1',
'credentials' => '/path/to/default.json',
'api_key' => null,
],
'vertex-anthropic' => [
'location' => 'europe-west1', // Overrides base location
'credentials' => '/path/to/anthropic.json', // Overrides base credentials
// project_id is inherited from base config
],
],
When using Vertex::Anthropic, the final config will be:
[
'project_id' => 'my-project', // from base
'location' => 'europe-west1', // overridden
'credentials' => '/path/to/anthropic.json', // overridden
'api_key' => null, // from base
]
Mixing Standard and Express modes
You can use Standard mode for some providers and Express mode for others:
// config/prism.php
'providers' => [
// Base config uses Standard mode
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => env('VERTEX_LOCATION', 'us-central1'),
'credentials' => env('VERTEX_CREDENTIALS'),
],
// Override Gemini to use Express mode with API key
'vertex-gemini' => [
'api_key' => env('VERTEX_GEMINI_API_KEY'),
'project_id' => null,
'location' => null,
'credentials' => null,
],
],
Remember that Express mode only supports Gemini models. You cannot use Express mode for Anthropic, Mistral, Meta, or other partner providers.
Runtime provider options
In addition to config-based overrides, you can pass provider-specific options at runtime using withProviderOptions():
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
use Prism\Vertex\Enums\VertexSchema;
$response = Prism::text()
->using(Vertex::Gemini, 'gemini-2.5-flash')
->withProviderOptions([
'apiSchema' => VertexSchema::Gemini,
'safetySettings' => [
['category' => 'HARM_CATEGORY_HATE_SPEECH', 'threshold' => 'BLOCK_NONE'],
],
'thinkingBudget' => 8192,
'includeThoughts' => true,
])
->withPrompt('Explain quantum computing')
->asText();
These options are request-specific and do not affect the provider configuration.
Available provider options
Gemini schema
Anthropic schema
OpenAI schema
apiSchema - Override the API schema (VertexSchema enum)
safetySettings - Array of safety threshold configs
thinkingBudget - Max thinking tokens for reasoning models
thinkingLevel - Thinking intensity level
includeThoughts - Include thinking process in response
thinkingConfig - Full thinking configuration object
apiSchema - Override the API schema (VertexSchema enum)
jsonModeMessage - Custom JSON instruction for structured output
apiSchema - Override the API schema (VertexSchema enum)
jsonModeMessage - Custom JSON instruction for structured output
Validation
Prism Vertex validates your configuration when the provider is instantiated. You’ll receive a PrismException if:
- You use Standard mode without
project_id and location
- You use Express mode without
api_key
- You use Express mode with a non-Gemini schema
- You specify
credentials but the file doesn’t exist
// This will throw an exception:
Prism::text()
->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
->withPrompt('Hello')
->asText();
// If vertex-anthropic config has:
'vertex-anthropic' => [
'api_key' => env('VERTEX_API_KEY'),
'project_id' => null,
'location' => null,
]
// Error: "Vertex AI Express mode only supports Google models.
// The anthropic apiSchema requires Standard mode with project_id and location."
Environment-specific overrides
You can use Laravel’s environment-specific config files to define different overrides per environment:
// config/prism.php (production)
'providers' => [
'vertex' => [
'project_id' => env('VERTEX_PROJECT_ID'),
'location' => 'us-central1',
'credentials' => env('VERTEX_CREDENTIALS'),
],
],
// config/testing/prism.php (testing)
'providers' => [
'vertex' => [
'project_id' => env('VERTEX_TEST_PROJECT_ID'),
'location' => 'us-central1',
'credentials' => env('VERTEX_TEST_CREDENTIALS'),
],
'vertex-gemini' => [
'api_key' => env('VERTEX_TEST_API_KEY'),
'project_id' => null,
'location' => null,
],
],