Vertex AI
Verified : Automated tests passed for: Configuration files: The configuration files on this page were checked against their schema. End-to-end run: Every step ran in a fresh test environment and the results were checked.Route agentgateway LLM traffic to models on Google Cloud Vertex AI.
Configure Google Cloud Vertex AI as an LLM provider in agentgateway.
Authentication
Before you can use Vertex AI as an LLM provider, you must authenticate by using Google Cloud’s Application Default Credentials. Choose from one of the three methods:
GOOGLE_APPLICATION_CREDENTIALSapplication_default_credentials.json- metadata server
Configuration
You can add the model in the UI or in your configuration file.
To add the model in the UI, follow these steps. The steps create the same model as the Config file tab.
Set up GCP Application Default Credentials (ADC) in the terminal where you run agentgateway.
Create a configuration file with an empty
llmsection, and start agentgateway in the same terminal. Without anllmsection, the UI does not show the LLM > Models page.cat > config.yaml <<'EOF' # yaml-language-server: $schema=https://agentgateway.dev/schema/config llm: models: [] EOF agentgateway -f config.yamlOpen LLM > Models, such as http://localhost:15000/ui/llm/models, and click Add model.
From the Provider dropdown, select Gemini Enterprise (GCP Vertex).
In the Incoming model match field, replace the default
vertex/*withgemini-2.5-flash.Keep ADC for the Google credentials. To use a service account key file instead, select File, and enter the path to the file.
Enter
my-project-idfor the Vertex project.For the Vertex region, enter or select
us-west2. If you leave the field empty, Vertex usesglobal.For the Outgoing model, select Explicit, and enter
google/gemini-2.5-flash-lite-preview-06-17.

Click Save model.
Whether the UI can save depends on your storage mode. For more information, see Save changes from the UI.
Reasoning effort
Set reasoning_effort in OpenAI-compatible Chat Completions requests to a Gemini model to configure Gemini thinking. For Gemini 2.5 and older models, reasoning_effort maps to thinkingConfig.thinkingBudget. For Gemini 3 and Gemini 4 models, reasoning_effort maps to thinkingConfig.thinkingLevel.
| Model family | reasoning_effort behavior |
|---|---|
| Gemini 2.5 and older | minimal, low, medium, high, xhigh, and max use thinkingBudget values. none omits thinkingConfig. |
| Gemini 3 | minimal, low, medium, high, xhigh, and max use thinkingLevel. none omits thinkingConfig. |
| Gemini 4 | minimal and low use thinkingLevel: "low". medium uses thinkingLevel: "medium". high, xhigh, and max use thinkingLevel: "high". none omits thinkingConfig. |
Send file content by URI
In an OpenAI-compatible Chat Completions request, you can put a gs://, http://, or https:// URI in a file content part’s file_data or file_id. The request to Vertex AI uses fileData.
For HTTP(S) signed URLs, MIME type detection uses the extension before the query string or fragment. If the URI does not have a recognized extension, set filename, mime_type, or content_type on the file object.
{
"model": "gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Compare these documents." },
{
"type": "file",
"file": {
"file_id": "https://storage.googleapis.com/my-bucket/report.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Signature=abc"
}
},
{
"type": "file",
"file": {
"filename": "summary.pdf",
"file_data": "https://example.com/download/123"
}
}
]
}
]
}Send images and files in Responses requests
For models other than Claude, agentgateway converts an OpenAI Responses request for Vertex AI to Chat Completions. Vertex AI has no Chat Completions file part, so the conversion sends both images and files as image_url parts.
- An
input_imagepart must setimage_url. Vertex AI does not accept theoriginalimage detail, so the conversion changesdetail: "original"tohigh. - An
input_filepart must carry the file as a base64 data URL, such asdata:application/pdf;base64,<base64>, infile_dataorfile_url. Thefilenameis not sent.
The conversion rejects a file that sets only file_id, a file_data value that is not a data URL, and a remote URL in file_url. It also rejects an image or file in a system, developer, or assistant message. To send a file by gs:// or HTTPS URI, use a Chat Completions request instead, as described in Send file content by URI.
Use structured outputs
For OpenAI-compatible Chat Completions requests, setresponse_format.type to json_schema to request structured JSON from a Gemini model. Agentgateway sends the schema to Gemini as responseJsonSchema. Standard JSON Schema keywords, such as $defs, $ref, anyOf, and additionalProperties, pass through unchanged. Tool definitions are handled differently. For schemas in tools[].function.parameters, agentgateway inlines $defs and $ref, removes fields that Gemini does not support, such as additionalProperties, and keeps a propertyOrdering field that you set.curl "localhost:4000/v1/chat/completions" -H content-type:application/json -d '{
"model": "gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": "Return one calendar event for tomorrow."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "calendar_event",
"strict": true,
"schema": {
"$defs": {
"CalendarEvent": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"date": { "type": "string" }
},
"required": ["name", "date"]
}
},
"type": "object",
"additionalProperties": false,
"properties": {
"event": { "$ref": "#/$defs/CalendarEvent" }
},
"required": ["event"]
}
}
}
}' | jqExample output, in which content is a JSON string that matches the schema:
{
"model": "gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"event\":{\"name\":\"Team sync\",\"date\":\"2026-11-25\"}}"
},
"finish_reason": "stop"
}
],
...
}Filter Anthropic beta headers
Vertex AI rejects a Claude request if the anthropic-beta header contains a value that Vertex AI does not support. Clients such as Claude Code send several of these values. When a /v1/messages or /v1/messages/count_tokens request reaches a Claude model on Vertex AI, agentgateway removes the anthropic-beta values that are not on a built-in allowlist. The allowlist has the beta values that Vertex AI accepts, such as context-1m-2025-08-07 and interleaved-thinking-2025-05-14.
To change the allowlist, set the AGENTGATEWAY_VERTEX_ANTHROPIC_BETA_HEADERS environment variable to a comma-separated list of beta values before you start agentgateway. The list replaces the built-in allowlist. Include the default value to keep the built-in allowlist and add to it. The following example keeps the built-in allowlist and adds one beta value.
export AGENTGATEWAY_VERTEX_ANTHROPIC_BETA_HEADERS="default,my-new-beta-2026-12-01"
agentgateway -f config.yamlWith this setting, a request with anthropic-beta: my-new-beta-2026-12-01,context-1m-2025-08-07,unsupported-beta reaches Vertex AI with anthropic-beta: my-new-beta-2026-12-01,context-1m-2025-08-07.