Google Vertex AI

Connect Gemini on Vertex AI to Agent Command Center with a service account, then set routing, timeouts and retries.

Connect Gemini models on Google Vertex AI with a service-account key. Agent Command Center builds the Vertex AI endpoint from your project and location, and renews the access token for you.

Add Vertex AI in the dashboard

Go to Gateway > Providers, click Add Provider and select Google Vertex AI. Fill in three fields:

FieldWhat to enter
Google Cloud project IDThe project that runs Vertex AI, for example my-gcp-project
Vertex AI locationglobal, or a region such as us-central1. See Global or regional location
Service-account JSONThe full JSON key of a service account. Paste the whole file

Vertex AI does not list its models in the dialog. Type each model ID, such as gemini-3.6-flash, and press Enter. Set Timeout before you save; see Timeouts. Click Add Provider.

You do not enter a base URL or an access token. The provider is named vertex. The dashboard keeps one Vertex AI provider per organization, so all its models use one location.

The key must meet these rules, or the dialog refuses it:

  • It is a service-account key: "type": "service_account", with client_email, private_key and project_id
  • token_uri is https://oauth2.googleapis.com/token
  • The private key is an RSA key

The key is stored encrypted and is never returned by the API. The service account needs permission to call Vertex AI models in the project, for example the Vertex AI User role.

Global or regional location

The location you pick sets the endpoint Agent Command Center calls:

LocationEndpoint
globalhttps://aiplatform.googleapis.com/v1beta1/projects/<project>/locations/global
A region, such as us-central1https://us-central1-aiplatform.googleapis.com/v1beta1/projects/<project>/locations/us-central1

Start with global. Some Gemini models are served only on the global endpoint, and a regional location returns 404 for them. Pick a region when your requests must be processed in that region, or when the model you need is offered only there. Google lists the locations for each model on Vertex AI locations.


Configure Vertex AI in config.yaml

On a self-hosted gateway you can declare the provider in config.yaml instead. Set api_format: gemini and put the project and location in base_url:

providers:
  vertex:
    api_format: gemini
    base_url: "https://aiplatform.googleapis.com/v1beta1/projects/my-gcp-project/locations/global"
    credentials_file: "/secrets/vertex-service-account.json"
    default_timeout: 180s
    models:
      - gemini-3.6-flash

The provider key (vertex here) is the prefix you route with. Pick one way to authenticate:

SettingBehaviour
credentials_filePath to a service-account JSON key file. The gateway renews the access token
service_account_jsonThe key’s JSON as a string, for example "${VERTEX_SERVICE_ACCOUNT_JSON}". The gateway renews the access token
None of the above, and no api_keyGateway v1.60.0 or later uses GOOGLE_APPLICATION_CREDENTIALS, or the service account of the GKE or Compute Engine workload it runs on. An earlier gateway sends no token
api_keySent as Authorization: Bearer <api_key> exactly as written and never renewed. A Google access token expires, so use this only for a short test

A base_url of https://aiplatform.googleapis.com with x-gcp-project and x-gcp-location under headers also works. The gateway adds the project and location path to it.


Route requests to Vertex AI

Name the provider in the model: <provider>/<model>. The dashboard provider is vertex, so vertex/gemini-3.6-flash goes to Vertex AI. The gateway sends Vertex AI the model name without the prefix.

from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.futureagi.com/v1",
    api_key="sk-agentcc-your-key",
)

response = client.chat.completions.create(
    model="vertex/gemini-3.6-flash",
    messages=[{"role": "user", "content": "Summarize this week's Gemini release notes."}],
    tools=[{"type": "google_search"}],
)

print(response.choices[0].message.content)
for source in response.choices[0].message.annotations or []:
    print(source.url_citation.url)
curl -X POST https://gateway.futureagi.com/v1/chat/completions \
  -H "Authorization: Bearer sk-agentcc-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vertex/gemini-3.6-flash",
    "messages": [{"role": "user", "content": "Summarize this week'\''s Gemini release notes."}],
    "tools": [{"type": "google_search"}]
  }'

In the dashboard, the prefix reaches Vertex AI only when the model is in the provider’s model list. A model the list does not have fails with model_not_found or “is not available for this API key”.

When Google AI Studio serves the same model

The Google (Gemini) provider is named google. When it and vertex both list gemini-3.6-flash, a request for the bare name gemini-3.6-flash goes to google: providers that list the same name are tried in name order.

To send a model to Vertex AI every time, use the vertex/ prefix. To make Vertex AI the default for the bare name, list the model on the Vertex AI provider only. In config.yaml, a bare name that two providers list is spread across both by the routing strategy, so the same two options apply.


Grounding and other Gemini tools

On /v1/chat/completions, Vertex AI runs these tools besides your own functions: google_search, google_search_retrieval, url_context and code_execution. Write a tool as {"type": "google_search"} or as {"google_search": {}}; the camelCase names, such as googleSearch, also work. The gateway leaves other tool types out of the request. A request left with no tool fails with 400 unsupported_tool.

Where the grounding sources come back:

RequestSources
Chat completion, not streamedmessage.annotations, one url_citation per source with its url and title. Each citation covers the whole answer
Chat completion, streamedNot returned
Gemini API routeGoogle’s groundingMetadata, unchanged

Grounding quota and billing belong to your Google Cloud project. A grounding quota error comes back like any other Vertex AI quota error; see Rate limits and retries. Cost tracking does not include Google’s charge for grounded requests.


Timeouts

The provider Timeout is the longest one call to Vertex AI may take, a streamed response included. It is 60 seconds for a provider added in the dashboard, and 120 seconds when default_timeout is not set in config.yaml. A call that runs past it fails with 504.

Grounded answers and long reasoning can take more than a minute. Set the Timeout to the longest call you expect, for example 180 seconds.

A request ends at the shortest of three limits: the provider Timeout, the timeout the request asks for, and the gateway’s maximum request time. A request asks for a timeout with the x-agentcc-timeout header, or through Model Timeouts in Gateway > Fallbacks. The x-agentcc-timeout-ms response header shows the limit that applied; see Request & response headers.

Max Concurrent caps the calls in flight to the provider; the default is 100. A call over the cap waits for a free slot, and fails with 504 if its timeout passes first.


Rate limits and retries

When your project runs out of Vertex AI quota, Google answers RESOURCE_EXHAUSTED. On /v1/chat/completions you get HTTP 429 with error.code set to provider_RESOURCE_EXHAUSTED.

Warning

Agent Command Center sends one attempt to your Vertex AI provider and returns the 429. The Retry and Provider Failover settings in Gateway > Fallbacks do not apply to a model that only your organization’s providers serve. On a self-hosted gateway they apply when failover is on and two or more providers in config.yaml serve the model. The Gemini API route never retries.

To absorb 429s:

  • Retry in your client with exponential backoff and jitter. The OpenAI SDK retries a 429 twice by default; raise it with OpenAI(..., max_retries=5)
  • Add a model fallback chain. In Gateway > Fallbacks, turn on Model Fallback Chains and add a chain, for example vertex/gemini-3.6-flash, then google/gemini-3.6-flash. While the toggle is on, a Vertex AI call that fails with 429, 500, 502, 503 or 504 moves to the next model. Every model in the chain must be in one of your providers’ model lists
  • Raise the quota. A steady stream of 429s means the project needs more Vertex AI quota; retries only smooth out short bursts

Gemini API route

The gateway also accepts requests in Google’s Gemini API format and forwards them to Vertex AI unchanged:

curl -X POST "https://gateway.futureagi.com/v1beta/models/vertex/gemini-3.6-flash:generateContent" \
  -H "Authorization: Bearer sk-agentcc-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "Summarize this week'\''s Gemini release notes."}]}],
    "tools": [{"googleSearch": {}}]
  }'

Send your gateway key in the Authorization header, as above. Use :streamGenerateContent for a streamed response. The response is Vertex AI’s own, and an error comes back with Vertex AI’s status and body.

Note

The Vertex AI API itself is not served. The Google Gen AI SDK with vertexai=True calls paths such as /v1beta1/projects/<project>/locations/<location>/..., and the gateway answers 404 Unknown endpoint. The Google Gen AI SDK is not supported with Vertex AI through the gateway; use /v1/chat/completions or the route above over HTTP.


Troubleshooting

What you seeCauseFix
404 Publisher model ... was not foundThe location does not serve the model, or the project cannot use itSwitch the location to global, or pick a region that serves the model
404 Unknown endpoint: /v1beta1/projects/...The client calls the Vertex AI API, for example the Google Gen AI SDK with vertexai=TrueCall /v1/chat/completions with vertex/<model>
model_not_found, or “is not available for this API key”The model is not in the Vertex AI provider’s model listAdd the model ID to the provider
401 provider_UNAUTHENTICATEDThe service-account key was deleted or disabledCreate a new key and paste it into the provider
403 provider_PERMISSION_DENIEDThe service account cannot call Vertex AI, or the Vertex AI API is off in the projectGrant the service account access to Vertex AI and turn on the API
429 provider_RESOURCE_EXHAUSTEDThe project is out of Vertex AI quota, grounding includedSee Rate limits and retries
504 after about 60 secondsThe call ran past the provider TimeoutRaise Timeout on the provider
400 unsupported_toolNo tool in the request is one Vertex AI can runUse a function or a tool listed in Grounding and other Gemini tools
”The JSON must be a Google service-account key with a project ID” when you saveThe pasted file is not a service-account keyCreate a JSON key for a service account and paste the whole file

Dive deeper

Was this page helpful?

Questions & Discussion