1
---
2
name: agent-platform-migrate-from-ai-studio
3
metadata:
4
version: "1.0.2"
5
category: AiAndMachineLearning
6
description: >-
7
Guides agents and users through migrating from Gemini API in Google AI Studio to Gemini Enterprise Agent Platform (formerly Vertex AI). Use this skill when moving applications to Google Cloud, to leverage Cloud credits, or to unify inferencing with other Cloud infrastructure (IAM, billing, telemetry).
8
---
9
10
# Migrating from Gemini API in AI Studio to Agent Platform
11
12
Use this skill when you need to transition an application from the
13
developer-centric Google AI Studio ecosystem
14
(`generativelanguage.googleapis.com`) to the enterprise-grade Google Cloud Agent
15
Platform (`aiplatform.googleapis.com`).
16
17
## Attribution
18
19
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
20
MUST read [Usage Attribution](references/attribution.md). For commands executed
21
directly in the terminal (never in generated scripts, Terraform, or user code),
22
prefix `gcloud` with
23
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:agent-platform-migrate-from-ai-studio)"`
24
and append
25
`agent-skills/1.0 (skill:agent-platform-migrate-from-ai-studio)`
26
to `User-Agent` headers.
27
28
--------------------------------------------------------------------------------
29
30
## When to Invoke This Skill
31
32
* You want to migrate an application from Google AI Studio to Agent Platform
33
(formerly Vertex AI).
34
* You have **Google Cloud credits** (e.g., the $300 Welcome Free Trial) that
35
you want to apply toward Gemini API inferencing costs.
36
* You need to unify your inferencing pipelines, IAM permissions, telemetry,
37
and billing with existing Google Cloud infrastructure (Compute Engine, Cloud
38
SQL, BigQuery).
39
* You are deploying open-source orchestration engines (like OpenClaw or ADK
40
agents) on Google Cloud VMs, and want the entire system to run under a
41
unified Google Cloud billing structure.
42
43
--------------------------------------------------------------------------------
44
45
## Gemini API Comparison
46
47
Feature / Control | Google AI Studio (Gemini Developer API) | Agent Platform (Enterprise Gemini API)
48
:--------------------- | :-------------------------------------------------------------------- | :-------------------------------------
49
**API Endpoint** | `generativelanguage.googleapis.com` | `aiplatform.googleapis.com`
50
**Target Audience** | Developers, startups, students, researchers building production apps. | Enterprise production, MLOps engineers
51
**GCP Credit Support** | No (GCP credits/Free Trial **cannot** be applied) | Yes (Fully covered by Welcome or custom credits)
52
**Data Privacy** | Data may be reviewed to improve Google products | Prompts/responses are **never** used for training
53
**Security & IAM** | API key, OAuth | Google Cloud IAM (Service Accounts, OAuth 2.0, VPC-SC)
54
**Compliance & SLAs** | None (Best-effort availability) | 24/7 Enterprise Support, SLAs, HIPAA, SOC2
55
**Throughput Options** | Shared / Rate-limited | Pay-as-you-go OR Provisioned Throughput
56
**MLOps Ecosystem** | Basic prompt management | Model Registry, Model Monitoring, Pipeline Evaluation
57
**Inferencing Scope** | Global endpoints only | Both Global and strict Regional endpoints
58
59
See
60
[Google Cloud Documentation](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/migrate/migrate-google-ai.md.txt)
61
to learn more about the differences between the two offerings.
62
63
--------------------------------------------------------------------------------
64
65
## Migration Guide
66
67
### Billing and Credits
68
69
Google Cloud Free Trial credits
70
**[do not apply to AI Studio](https://docs.cloud.google.com/free/docs/free-cloud-features.md.txt)**.
71
To use your credits for Gemini models, you must route calls through the Agent
72
Platform.
73
74
1. Create a Google Cloud billing account. You must provide a valid payment
75
method during setup to verify identity.
76
2. If you are a new customer, ensure your $300 Welcome credit is active in the
77
Billing Console.
78
3. **Avoid Billing Surprises:** To prevent automatic fallback to your standard
79
form of payment when credits are exhausted, you should establish a budget
80
alert:
81
* Go to **Billing** -> **Budgets & Alerts** -> **Create Budget**.
82
* Set the threshold to map to your credit limit or maximum comfortable
83
spend.
84
85
### Enable the Agent Platform API
86
87
You must explicitly enable the Agent Platform API on your target Google Cloud
88
Project. Run the following command via your local shell:
89
90
```bash
91
gcloud services enable aiplatform.googleapis.com --project="{project_id}"
92
```
93
94
### Authentication & Authorization (IAM)
95
96
#### User Auth
97
98
For local debugging or script execution, authenticate using
99
[Application Default Credentials](https://docs.cloud.google.com/docs/authentication/application-default-credentials.md.txt)
100
(ADC).
101
102
**Option 1 - Automated Script**:
103
104
```bash
105
bash <(curl -sSL https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.sh)
106
```
107
108
**Option 2 - Manual Setup**:
109
110
```bash
111
gcloud auth login
112
gcloud auth application-default login
113
```
114
115
Grant your user identity the required IAM role to perform inferencing calls:
116
117
```bash
118
gcloud projects add-iam-policy-binding "{project_id}" \
119
--member="user:YOUR_EMAIL@domain.com" \
120
--role="roles/aiplatform.user"
121
```
122
123
#### Service Auth
124
125
When running your application on Google Cloud infrastructure such as a Compute
126
Engine VM, authenticate using the machine's attached Service Account. For
127
example, the
128
[Compute Engine Default Service Account](https://docs.cloud.google.com/compute/docs/access/service-accounts#default_service_account.md.txt).
129
130
1. Grant the virtual machine's underlying Service Account the user role:
131
132
```bash
133
gcloud projects add-iam-policy-binding "{project_id}" \
134
--member="serviceAccount:PROJECT_NUMBER-compute@developer.gserviceaccount.com" \
135
--role="roles/aiplatform.user"
136
```
137
138
2. **[Compute Engine Access Scopes](https://docs.cloud.google.com/compute/docs/access/service-accounts.md.txt):**
139
Legacy access scopes can override IAM bindings. When provisioning or
140
modifying your Compute Engine instance, you must verify that the VM access scope is
141
configured to either **Allow full access to all Cloud APIs**
142
(`https://www.googleapis.com/auth/cloud-platform`) or explicitly includes
143
the standard cloud-platform scope.
144
145
--------------------------------------------------------------------------------
146
147
## Use the Gemini API in Agent Platform
148
149
### SDKs (Client Libraries)
150
151
You can continue to use the unified
152
[Google GenAI SDK](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/sdks/overview.md.txt)
153
(`google-genai`). This SDK works with both AI Studio and Agent Platform. You
154
only need to switch the routing flags via your runtime environment variables to
155
target the Agent Platform backend.
156
157
Set your target environment details:
158
159
```bash
160
export GOOGLE_CLOUD_PROJECT="{project_id}"
161
export GOOGLE_CLOUD_LOCATION="global" # Or your chosen regional endpoint
162
export GOOGLE_GENAI_USE_ENTERPRISE=TRUE
163
```
164
165
Now, your standard python code shifts from using AI Studio to Agent Platform
166
without altering the core initialization blocks:
167
168
```python
169
from google import genai
170
171
# The client automatically picks up the GOOGLE_GENAI_USE_ENTERPRISE=TRUE environment flag
172
client = genai.Client()
173
174
response = client.models.generate_content(
175
model='gemini-3.5-flash',
176
contents='Hello world!',
177
)
178
print(response.text)
179
```
180
181
### Agent Development Kit (ADK)
182
183
To call Gemini models in Agent Platform from an Agent Development Kit agent,
184
follow these steps.
185
186
1. Authenticate to Google Cloud.
187
188
If running an ADK agent in Google Cloud (e.g. Agent Platform Runtime), use the
189
agent's assigned service account. Alternatively, if running ADK locally, run:
190
191
```bash
192
gcloud auth application-default login
193
```
194
195
1. Set env variables. Ensure these are set no matter if your ADK agent is
196
running in Google Cloud or locally:
197
198
```bash
199
export GOOGLE_CLOUD_PROJECT="{project_id}"
200
export GOOGLE_CLOUD_LOCATION="global"
201
export GOOGLE_GENAI_USE_ENTERPRISE=TRUE
202
```
203
204
2. Initialize the ADK agent. You can use the same model string you used with AI
205
Studio (e.g. `gemini-3.5-flash`).
206
207
```python
208
from google.adk.agents.llm_agent import Agent
209
210
def get_current_time(city: str) -> dict:
211
"""Returns the current time in a specified city."""
212
return {"status": "success", "city": city, "time": "10:30 AM"}
213
214
root_agent = Agent(
215
model='gemini-3.5-flash',
216
name='root_agent',
217
description="Tells the current time in a specified city.",
218
instruction="You are a helpful assistant that tells the current time in cities. Use the 'get_current_time' tool for this purpose.",
219
tools=[get_current_time],
220
)
221
```
222
223
To learn more about integrating ADK agents with Agent Platform,
224
[see the ADK documentation](https://adk.dev/agents/models/agent-platform/).
225
226
### Antigravity CLI
227
228
Google Cloud users [can now access](https://antigravity.google/pricing)
229
Antigravity 2.0, including the Antigravity CLI, with Gemini Enterprise Agent
230
Platform.
231
232
1. [Install the Antigravity CLI](https://antigravity.google/docs/cli-install)
233
to your local environment.
234
2. Start the Antigravity CLI.
235
236
```bash
237
agy
238
```
239
240
3. Follow the CLI setup prompts - select **Use a Google Cloud Project**.
241
242
4. Complete the OAuth flow in the opened browser window using your
243
authenticated Google Cloud Workspace or user identity.
244
245
5. Copy the confirmation token, and paste it directly back into your terminal.
246
247
6. Follow the prompts to enter your Google Cloud Project ID.
248
249
7. Select your Google Cloud location (e.g. `global`).
250
251
8. Optionally, run the `/model` command to select a different Gemini model in
252
Agent Platform.
253
254
### OpenClaw
255
256
To configure an OpenClaw agent to use Gemini models in Agent Platform, Follow
257
these steps.
258
259
1. [Install OpenClaw using OpenClaw's official instructions](https://docs.openclaw.ai/install).
260
261
⚠️ Important: OpenClaw 2026.5.28 currently has a `google-vertex` bug. Please use
262
2026.5.20 for now.
263
264
2. Ensure that the runtime where OpenClaw is running (e.g. GCE VM with Service
265
Account) has the `roles/aiplatform.user` IAM role - see Authentication and
266
Authorization section above.
267
268
3. Get the project number from the user's project ID. Outside of GCE, run:
269
270
```bash
271
export PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format="value(projectNumber)")
272
echo "Project number: $PROJECT_NUMBER"
273
274
```
275
276
Within a Compute Engine VM, run:
277
278
```bash
279
export PROJECT_NUMBER=$(curl "http://metadata.google.internal/computeMetadata/v1/project/numeric-project-id" -H "Metadata-Flavor: Google")
280
echo "Project number: $PROJECT_NUMBER"
281
```
282
283
4. From outside the GCE instance, generate `GOOGLE_APPLICATION_CREDENTIALS`
284
using the Google Cloud project number. Then, `scp` these credentials to the
285
GCE VM.
286
287
```bash
288
mkdir -p ~/.config/gcloud
289
gcloud iam service-accounts keys create ~/.config/gcloud/application_default_credentials.json --iam-account="${PROJECT_NUMBER}-compute@developer.gserviceaccount.com"
290
```
291
292
> ⚠️ **Troubleshooting Policy Constraints on New Orgs**: New Google
293
> Cloud organizations (created on or after May 4th, 2024) enforce a [legacy Organization Policy, restricting Service Account Key Creation](https://docs.cloud.google.com/organization-policy/restrict-service-accounts.md.txt). To complete this step, this Org Policy must be temporarily disabled.
294
> An Organization Policy Admin must set this policy to Inactive.
295
> To the agent: Check if this policy is enforced, and if it is: pause, and
296
> prompt the user to disable it at this Console link:
297
> https://console.cloud.google.com/iam-admin/orgpolicies
298
299
300
5. Edit the configuration file that's usually located at:
301
`~/.openclaw/openclaw.json`. Ensure you prefix the Gemini model with
302
`google-vertex/`.
303
304
> ⚠️ Important: Do not use Gemini 3.5 models, since OpenClaw's `google-vertex`
305
> provider does not support it yet. Older models work. When using the
306
> [Gemini 3 Flash Preview](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-flash)
307
> model in Agent Platform, always set the location to `global`, NOT a regional
308
> endpoint.
309
310
```json
311
{
312
"env": {
313
"vars": {
314
"GOOGLE_CLOUD_PROJECT": "PROJECT_ID",
315
"GOOGLE_CLOUD_LOCATION": "global",
316
"GOOGLE_APPLICATION_CREDENTIALS": "~/.config/gcloud/application_default_credentials.json"
317
}
318
},
319
"agents": {
320
"defaults": {
321
"model": {
322
"primary": "google-vertex/gemini-3-flash-preview"
323
},
324
"workspace": "~/.openclaw/workspace",
325
"compaction": {
326
"mode": "safeguard"
327
},
328
"heartbeat": {
329
"model": "google-vertex/gemini-3-flash-preview"
330
}
331
},
332
"list": [
333
{
334
"id": "main",
335
"workspace": "~/.openclaw/workspace",
336
"model": "google-vertex/gemini-3-flash-preview"
337
}
338
]
339
},
340
"session": {
341
"dmScope": "per-channel-peer"
342
},
343
"tools": {
344
"profile": "coding"
345
}
346
}
347
348
```
349
350
6. Restart OpenClaw.
351
352
```bash
353
openclaw gateway restart
354
355
```
356
357
7. Verify the OpenClaw connection to Agent Platform:
358
359
```bash
360
openclaw models status
361
openclaw agent --agent main --message "Hello world!"
362
363
```
364
365
--------------------------------------------------------------------------------
366
367
## Additional Resources
368
369
* [Google Cloud Free Trial Features & Limits](https://docs.cloud.google.com/free/docs/free-cloud-features.md.txt)
370
* [Migrate from Google AI Studio to Gemini Enterprise Agent Platform](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/migrate/migrate-google-ai.md.txt)
371
* [Gemini Enterprise Agent Platform - Models](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/google-models.md.txt)
372
* [Agent Development Kit Documentation - Connect to Models in Agent Platform](https://adk.dev/agents/models/agent-platform/#agent-platform-setup)
373
* [OpenClaw Documentation - Connect to Google models](https://docs.openclaw.ai/providers/google)
374
* [Google Cloud Budget Alerts - Setup Guide](https://docs.cloud.google.com/billing/docs/how-to/budgets#steps-to-create-budget.md.txt)
375