Skip to content
Help guide the future of agentgateway — Take the survey

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.
Page as Markdown

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_CREDENTIALS
  • application_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.

  1. Set up GCP Application Default Credentials (ADC) in the terminal where you run agentgateway.

  2. Create a configuration file with an empty llm section, and start agentgateway in the same terminal. Without an llm section, 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.yaml
  3. Open LLM > Models, such as http://localhost:15000/ui/llm/models, and click Add model.

  4. From the Provider dropdown, select Gemini Enterprise (GCP Vertex).

  5. In the Incoming model match field, replace the default vertex/* with gemini-2.5-flash.

  6. Keep ADC for the Google credentials. To use a service account key file instead, select File, and enter the path to the file.

  7. Enter my-project-id for the Vertex project.

  8. For the Vertex region, enter or select us-west2. If you leave the field empty, Vertex uses global.

  9. For the Outgoing model, select Explicit, and enter google/gemini-2.5-flash-lite-preview-06-17.

    Add model drawer with Gemini Enterprise (GCP Vertex) selected as the provider, gemini-2.5-flash as the incoming model match, ADC as the Google credentials, my-project-id as the Vertex project, us-west2 as the Vertex region, and google/gemini-2.5-flash-lite-preview-06-17 as the explicit outgoing model
    Add model drawer with Gemini Enterprise (GCP Vertex) selected as the provider, gemini-2.5-flash as the incoming model match, ADC as the Google credentials, my-project-id as the Vertex project, us-west2 as the Vertex region, and google/gemini-2.5-flash-lite-preview-06-17 as the explicit outgoing model
  10. 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 familyreasoning_effort behavior
Gemini 2.5 and olderminimal, low, medium, high, xhigh, and max use thinkingBudget values. none omits thinkingConfig.
Gemini 3minimal, low, medium, high, xhigh, and max use thinkingLevel. none omits thinkingConfig.
Gemini 4minimal 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_image part must set image_url. Vertex AI does not accept the original image detail, so the conversion changes detail: "original" to high.
  • An input_file part must carry the file as a base64 data URL, such as data:application/pdf;base64,<base64>, in file_data or file_url. The filename is 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, set response_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"]
      }
    }
  }
}' | jq

Example 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.yaml

With 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.

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate ↵ select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.