# Route AI Traffic to Gemini Enterprise Agent Platform

[Gemini Enterprise Agent Platform](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models) is the current name for the Google Cloud model platform previously documented as Vertex AI. It provides Gemini and partner models through Google Cloud authentication and regional endpoints. This guide routes Agent Platform traffic through API7 Gateway with the [`ai-proxy`](https://docs.api7.ai/hub/ai-proxy.md) plugin. The released provider identifier remains `vertex-ai`.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

* Install [Docker](https://docs.docker.com/get-docker/).

* Install [cURL](https://curl.se/) to send requests to the services for validation.

* Install [`jq`](https://jqlang.org/download/) to encode the service-account key for the Admin API request.

* Have a running API7 Gateway instance.

* Have a Google Cloud project with billing and the [Agent Platform API enabled](https://console.cloud.google.com/apis/library/aiplatform.googleapis.com).

* Create a [token from the Dashboard](https://docs.api7.ai/api7-gateway/reference/obtain-dashboard-token.md) and save it to an environment variable:

  ```
  export API_KEY=your-dashboard-token   # replace with your Dashboard token
  ```

* Replace `{gateway_group_id}` with your gateway group ID. Use `default` if you are following the quickstart.

* If you are following the Admin API examples, create or reuse a service in API7 Gateway. If you do not have one yet, follow [Create or Reuse a Service](https://docs.api7.ai/api7-gateway/ai-gateway/get-started.md#create-or-reuse-a-service), then save its ID to an environment variable:

  ```
  export SERVICE_ID=your-service-id         # replace with your service ID
  ```

## Configure GCP Authentication[​](#configure-gcp-authentication "Direct link to Configure GCP Authentication")

Create a service account, grant it the Agent Platform User (`roles/aiplatform.user`) role, and [create a JSON service-account key](https://docs.cloud.google.com/iam/docs/keys-create-delete). API7 Gateway requires the downloaded key because it does not discover Application Default Credentials or Workload Identity Federation credentials.

Save the raw key for ADC and a JSON-encoded string for the Admin API request:

```
export GCP_SERVICE_ACCOUNT_JSON="$(cat /path/to/service-account.json)"

export GCP_SERVICE_ACCOUNT_JSON_STRING="$(jq -Rs . < /path/to/service-account.json)"
```

The gateway automatically handles OAuth2 token generation and caching from the service-account credentials.

## Configure the AI Proxy for Agent Platform[​](#configure-the-ai-proxy-for-agent-platform "Direct link to Configure the AI Proxy for Agent Platform")

Create a route with the [`ai-proxy`](https://docs.api7.ai/hub/ai-proxy.md) plugin:

* Admin API
* ADC

```
curl -k "https://localhost:7443/apisix/admin/routes/vertex-ai-route?gateway_group_id={gateway_group_id}" -X PUT \

  -H "X-API-KEY: ${API_KEY}" \

  -H "Content-Type: application/json" \

  --data-binary @- <<EOF

  {

    "name": "vertex-ai-route",

    "service_id": "$SERVICE_ID",

    "paths": ["/vertex-ai"],

    "plugins": {

      "ai-proxy": {

        "provider": "vertex-ai",

        "override": {

          "endpoint": "https://aiplatform.googleapis.com/v1beta1/projects/<GCP_PROJECT_ID>/locations/global/endpoints/openapi/chat/completions"

        },

        "auth": {

          "gcp": {

            "service_account_json": $GCP_SERVICE_ACCOUNT_JSON_STRING

          }

        },

        "options": {

          "model": "google/gemini-3.5-flash"

        }

      }

    }

  }

EOF
```

❶ Set the provider to `vertex-ai` and override its endpoint with the documented global Chat Completions URL. Replace `<GCP_PROJECT_ID>` with your project ID.

❷ Provide the GCP service account JSON. The gateway generates and caches OAuth2 tokens automatically.

❸ Set an Agent Platform model that supports Chat Completions on the global endpoint. The example uses `google/gemini-3.5-flash`, which supports the default Standard PayGo consumption mode on `global`.

adc.yaml

```
services:

  - name: Agent Platform Service

    routes:

      - uris:

          - /vertex-ai

        name: vertex-ai-route

        plugins:

          ai-proxy:

            provider: vertex-ai

            override:

              endpoint: https://aiplatform.googleapis.com/v1beta1/projects/<GCP_PROJECT_ID>/locations/global/endpoints/openapi/chat/completions

            auth:

              gcp:

                service_account_json: ${GCP_SERVICE_ACCOUNT_JSON}

            options:

              model: google/gemini-3.5-flash

    labels:

      docs-example: agent-platform-service
```

❶ Set the provider to `vertex-ai` and override its endpoint with the documented global Chat Completions URL. Replace `<GCP_PROJECT_ID>` with your project ID.

❷ Provide the GCP service account JSON. The gateway generates and caches OAuth2 tokens automatically.

❸ Set an Agent Platform model that supports Chat Completions on the global endpoint. The example uses `google/gemini-3.5-flash`, which supports the default Standard PayGo consumption mode on `global`.

Preview the changes owned by this example and confirm that the diff contains no unintended updates or deletions:

```
adc diff -f adc.yaml \

  --include-resource-type service \

  --label-selector docs-example=agent-platform-service
```

Synchronize the reviewed configuration:

```
adc sync -f adc.yaml \

  --include-resource-type service \

  --label-selector docs-example=agent-platform-service
```

The global endpoint is explicit because the released `vertex-ai` driver otherwise derives a regional hostname from `provider_conf.region`.

## Validate the Configuration[​](#validate-the-configuration "Direct link to Validate the Configuration")

Send a chat completion request:

```
curl "http://127.0.0.1:9080/vertex-ai" -X POST \

  -H "Content-Type: application/json" \

  -d '{

    "messages": [

      { "role": "system", "content": "You are a mathematician." },

      { "role": "user", "content": "What is 1+1?" }

    ]

  }'
```

You should receive a response similar to the following:

```
{

  "object": "chat.completion",

  "model": "google/gemini-3.5-flash",

  "choices": [

    {

      "index": 0,

      "message": {

        "role": "assistant",

        "content": "1 + 1 = 2\n"

      },

      "finish_reason": "stop"

    }

  ],

  "usage": {

    "prompt_tokens": 11,

    "completion_tokens": 8,

    "total_tokens": 19

  }

}
```

To enable streaming responses, set `"stream": true` in the request body. Use the [`proxy-buffering`](https://docs.api7.ai/hub/proxy-buffering.md) plugin to disable NGINX `proxy_buffering` to avoid server-sent events (SSE) being buffered.

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have connected API7 Gateway to Gemini Enterprise Agent Platform. See the [Agent Platform model catalog](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/google-models) and [OpenAI-compatible Chat Completions documentation](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/migrate/openai/overview) for supported models and request fields.

* [Multi-LLM Routing and Fallback](https://docs.api7.ai/api7-gateway/ai-gateway/use-cases/multi-llm-routing-and-fallback.md) — Route across regions or failover to other providers.
* [Google Gemini](https://docs.api7.ai/api7-gateway/ai-gateway/llm-providers/google-gemini.md) — Use the Gemini AI Studio API for lighter workloads.
