Prism Vertex uses three distinct API schemas to communicate with the various model providers available through Vertex AI. Each schema corresponds to a different API format and endpoint structure.
The three schemas
| Schema | Text | Structured | Embeddings | Endpoint |
|---|
| Gemini | ✓ | ✓ | ✓ | generateContent / predict |
| Anthropic | ✓ | ✓ | ✗ | :rawPredict |
| OpenAI | ✓ | ✓ | ✗ | :rawPredict / :chatCompletions |
Gemini schema
The Gemini schema uses Google’s native Vertex AI endpoints:
- Text generation:
generateContent endpoint
- Embeddings:
predict endpoint
- Structured output: Native via
response_mime_type: application/json and response_schema
- Publisher: Always
google
- Models:
gemini-2.5-flash, gemini-2.0-pro, text-embedding-005, etc.
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
$response = Prism::text()
->using(Vertex::Gemini, 'gemini-2.5-flash')
->withPrompt('Explain quantum computing')
->asText();
Anthropic schema
The Anthropic schema uses the :rawPredict endpoint with the Anthropic Messages API format:
- Text generation:
:rawPredict with Anthropic Messages API body format
- Structured output: Prompt-based (appends JSON instruction to your prompt)
- API version:
vertex-2023-10-16 (set automatically)
- Publisher: Always
anthropic
- Models:
claude-3-5-sonnet@20241022, claude-3-5-haiku@20241022, etc.
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
$response = Prism::text()
->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
->withPrompt('Explain quantum computing')
->asText();
OpenAI schema
The OpenAI schema uses OpenAI-compatible endpoints for partner models (Mistral, Meta, DeepSeek, AI21, Kimi, MiniMax, OpenAI-OSS, Qwen, ZAI):
- Text generation:
:rawPredict or :chatCompletions depending on publisher
- Structured output:
response_format: { type: "json_object" } with schema instruction
- Publisher: Varies by model (see table below)
- Models:
mistral-small-2503, llama-4-scout-17b-16e-instruct-maas, deepseek-v3-0324-maas, etc.
| Publisher | Models | Endpoint |
|---|
mistralai | mistral-*, mixtral-*, codestral-* | :rawPredict |
ai21 | jamba-* | :rawPredict |
meta | llama-* | :chatCompletions |
deepseek | deepseek-* | :chatCompletions |
kimi | kimi-* | :chatCompletions |
minimax | minimax-* | :chatCompletions |
openai | gpt-oss-* | :chatCompletions |
qwen | qwen* | :chatCompletions |
zaiorg | glm-* | :chatCompletions |
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
// Mistral (uses rawPredict)
$response = Prism::text()
->using(Vertex::Mistral, 'mistral-small-2503')
->withPrompt('Explain quantum computing')
->asText();
// Meta (uses chatCompletions)
$response = Prism::text()
->using(Vertex::Meta, 'llama-4-scout-17b-16e-instruct-maas')
->withPrompt('Explain quantum computing')
->asText();
Schema detection
Prism Vertex automatically detects the correct schema from your model string using VertexSchema::fromModelString(). The detection logic follows these rules:
Anthropic detection
OpenAI detection
Gemini detection
Models are mapped to the Anthropic schema if they:
- Start with
claude-
- Contain
@ (version delimiter)
// These all use Anthropic schema:
'claude-3-5-sonnet@20241022'
'claude-3-5-haiku@20241022'
'claude-3-opus@20240229'
Models are mapped to the OpenAI schema if they match any of these patterns:
- Start with
mistral, mixtral, or codestral (Mistral AI)
- Start with
llama or meta/ (Meta)
- Start with
deepseek (DeepSeek)
- Start with
jamba or ai21/ (AI21 Labs)
- Start with
kimi (Moonshot AI)
- Start with
minimax (MiniMax)
- Start with
gpt-oss (OpenAI OSS)
- Start with
qwen (Alibaba)
- Start with
glm (Zhipu AI / ZAI.org)
// These all use OpenAI schema:
'mistral-small-2503'
'llama-4-scout-17b-16e-instruct-maas'
'deepseek-v3-0324-maas'
'jamba-1.5-mini@001'
'kimi-k2-0711-maas'
'minimax-m1-40k-0709-maas'
'gpt-oss-4o-mini-maas'
'qwen2.5-72b-instruct-maas'
'glm-4-plus-maas'
All other models default to the Gemini schema:// These use Gemini schema:
'gemini-2.5-flash'
'gemini-2.0-pro'
'text-embedding-005'
'text-multilingual-embedding-002'
Overriding the schema
You can override the automatic schema detection using withProviderOptions():
use Prism\Prism\Prism;
use Prism\Vertex\Enums\Vertex;
use Prism\Vertex\Enums\VertexSchema;
$response = Prism::text()
->using(Vertex::Gemini, 'some-custom-model')
->withProviderOptions(['apiSchema' => VertexSchema::OpenAI])
->withPrompt('Hello')
->asText();
Overriding the schema can cause requests to fail if the model doesn’t support the specified schema format. Only override when you know the model is compatible with a different schema.
Structured output differences
Each schema handles structured output differently:
Gemini: Native JSON mode
Gemini uses native structured output via response_mime_type and response_schema. The model is constrained to produce valid JSON matching your schema.
use Prism\Prism\Prism;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;
use Prism\Vertex\Enums\Vertex;
$schema = new ObjectSchema(
name: 'answer',
properties: [
new StringSchema('text', 'The answer'),
]
);
$response = Prism::structured()
->using(Vertex::Gemini, 'gemini-2.5-flash')
->withSchema($schema)
->withPrompt('What is the capital of France?')
->asStructured();
// Guaranteed valid JSON matching schema
$data = $response->structured;
OpenAI: JSON mode with schema instruction
OpenAI schema uses response_format: { type: "json_object" } combined with a schema instruction message.
use Prism\Prism\Prism;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;
use Prism\Vertex\Enums\Vertex;
$schema = new ObjectSchema(
name: 'answer',
properties: [
new StringSchema('text', 'The answer'),
]
);
$response = Prism::structured()
->using(Vertex::Mistral, 'mistral-small-2503')
->withSchema($schema)
->withPrompt('What is the capital of France?')
->asStructured();
You can customize the schema instruction message:
$response = Prism::structured()
->using(Vertex::Mistral, 'mistral-small-2503')
->withSchema($schema)
->withProviderOptions([
'jsonModeMessage' => 'Respond with JSON matching this schema exactly.',
])
->withPrompt('What is the capital of France?')
->asStructured();
Anthropic: Prompt-based JSON
Anthropic has no native JSON mode. A prompt is appended instructing the model to respond with JSON conforming to the schema.
use Prism\Prism\Prism;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;
use Prism\Vertex\Enums\Vertex;
$schema = new ObjectSchema(
name: 'answer',
properties: [
new StringSchema('text', 'The answer'),
]
);
$response = Prism::structured()
->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
->withSchema($schema)
->withPrompt('What is the capital of France?')
->asStructured();
Customize the JSON instruction:
$response = Prism::structured()
->using(Vertex::Anthropic, 'claude-3-5-sonnet@20241022')
->withSchema($schema)
->withProviderOptions([
'jsonModeMessage' => 'Your response must be valid JSON conforming to the schema.',
])
->withPrompt('What is the capital of France?')
->asStructured();
Anthropic and OpenAI schemas may not always return perfectly valid JSON, especially with complex schemas. Gemini’s native JSON mode provides the strongest guarantees.
Express mode limitations
Express mode (API key only, no project_id/location) only supports the Gemini schema:
// config/prism.php
'vertex' => [
'api_key' => env('VERTEX_API_KEY'),
// project_id and location omitted = Express mode
],
Attempting to use Anthropic or OpenAI schemas in Express mode will throw a PrismException:Vertex AI Express mode only supports Google models. The anthropic apiSchema requires Standard mode with project_id and location.
To use partner models (Anthropic, Mistral, Meta, etc.), you must configure Standard mode with project_id and location.