Google Cloud Developer Training & Resource Guide
Technology: google-cloud · Category: hosting · Last reviewed: 2026-10-20
Source: https://tech-stack.codeamanilabs.org/guide/google-cloud
Insight:
Google Cloud is the heavyweight option: a full compute spectrum (Cloud Run functions → Cloud Run → GKE → Compute Engine), every database shape, and first-class AI. Three facts changed in 2026 and matter most. (1) Vertex AI is now "Gemini Enterprise Agent Platform" (renamed 2026-04-22); the API is still
aiplatform.googleapis.comand the SDK flag is stillvertexai: true. (2) Gemini 2.5 retires on Google Cloud on 2026-10-20. Usegemini-3.8-flash(GA) as the workhorse,gemini-3.5-flash-litefor cheap volume, andgemini-4-argon(GA 2026-10-13) for frontier work, all on thegloballocation. (3) Claude runs here too (claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5,claude-fable-5-1) at Anthropic list price on the global endpoint, +10% onus/eu/regional. Auth is keyless: ADC locally, the attached service account on Cloud Run, and Workload Identity Federation from GitHub Actions and Vercel.africa-south1(Johannesburg) hosts Cloud Run, Firestore, Cloud SQL, BigQuery and Secret Manager at Tier-1 prices, but no Gemini or Claude endpoint. Prices reviewed 2026-10-20; the Pricing Calculator wins.
██████╗ ██████╗ ██████╗ ██████╗ ██╗ ███████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗
██╔════╝ ██╔═══██╗██╔═══██╗██╔════╝ ██║ ██╔════╝ ██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗
██║ ███╗██║ ██║██║ ██║██║ ███╗██║ █████╗ ██║ ██║ ██║ ██║██║ ██║██║ ██║
██║ ██║██║ ██║██║ ██║██║ ██║██║ ██╔══╝ ██║ ██║ ██║ ██║██║ ██║██║ ██║
╚██████╔╝╚██████╔╝╚██████╔╝╚██████╔╝███████╗███████╗ ╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝
╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝
Google Cloud Developer Training & Resource Guide
Focus: A developer's working map of Google Cloud: what each service is for, how to implement it (gcloud + SDK), what it costs (official list prices + free tier), and where it bites. Sourced from
cloud.google.comanddocs.cloud.google.com; pricing and model IDs reviewed 2026-10-20. Prices change, so always confirm on the Pricing Calculator.
What changed since the last review (2026-08-23)
| Was | Now (2026-10-20) |
|---|---|
| "Vertex AI" | Gemini Enterprise Agent Platform ("Agent Platform"). Renamed 2026-04-22. API host aiplatform.googleapis.com, IAM roles roles/aiplatform.* and the Gen AI SDK's vertexai: true flag are unchanged. Docs moved to docs.cloud.google.com/gemini-enterprise-agent-platform. |
gemini-2.5-flash / gemini-2.5-pro as the GA defaults |
Retired on Google Cloud 2026-10-20. Replacements per Google: gemini-3.8-flash (GA 2026-09-02) or gemini-3.5-flash; gemini-3.5-flash-lite for the old Flash-Lite slot. Frontier: gemini-4-argon (GA 2026-10-13). |
location="us-central1" for Gemini |
Gemini 3.x / 4 models are served from global, us, eu only. Use global unless you need residency. |
| Agent Engine | Renamed Agent Runtime; Memory Bank and Sessions keep their names under Agent Platform. The quickstart now uses agents-cli. |
| Cloud Run: one rate card | Two rate cards. Instance-based $0.000018/vCPU-s + $0.000002/GiB-s, free 240k vCPU-s + 450k GiB-s. Request-based $0.000024/vCPU-s + $0.0000025/GiB-s active, $0.40/M requests, free 180k vCPU-s + 360k GiB-s + 2M requests. The old guide mixed them. |
| "GCP has no first-party MCP server" | Google now hosts remote MCP servers for Cloud Run, Firestore, IAM, Logging, Monitoring, GKE, Compute, Pub/Sub, Cloud SQL, Spanner and more (https://<service>.googleapis.com/mcp). |
| Claude on Vertex (not covered) | New section: Claude on Google Cloud with @anthropic-ai/vertex-sdk 0.21.0. |
| WIF for GitHub only | Keyless auth from GitHub Actions (google-github-actions/auth v3) and Vercel (@vercel/oidc). |
How to use this guide
This is a training resource, not just an integration cheat-sheet. Read it in three passes:
- Mental model: The GCP spine and the compute decision tree. Internalise these and most "which service?" questions answer themselves.
- Service-by-service: each section gives Use case · Implement · Cost · Gotcha. Skim, then dive where you need.
- Hands-on: the interactive learn module above this page (Cloud Run cost explorer), the runnable files in
examples/, the official learning paths, and the codeAmani notes.
Per the codeAmani docs policy, when you implement against any of these APIs, pull current docs via the Context7 MCP (
resolve-library-id→query-docs) or the official URL in each section. Don't code from memory; GCP ships fast.
The GCP spine (a mental model)
Google Cloud is the infrastructure Google runs Search, Gmail and YouTube on, rented out. Ignore the 200-product catalogue; a product developer reaches for about 30 services across eight layers:
| Layer | Services you'll actually use |
|---|---|
| Compute | Cloud Run · Cloud Run functions · GKE · Compute Engine · App Engine |
| Databases | Cloud SQL · AlloyDB · Spanner · Firestore · Bigtable · Memorystore |
| Analytics | BigQuery · Dataflow · Pub/Sub |
| Storage | Cloud Storage · Persistent Disk · Filestore |
| AI / ML | Gemini Enterprise Agent Platform (formerly Vertex AI): Gemini, Claude and open models via Model Garden, Agent Runtime, RAG Engine, Vector Search |
| Networking | VPC · Cloud Load Balancing · Cloud CDN · Cloud Armor · Cloud DNS |
| Security & Identity | IAM · Secret Manager · Cloud KMS · Workload Identity Federation |
| DevOps & Ops | Cloud Build · Artifact Registry · Cloud Deploy · Cloud Logging/Monitoring · Cloud Scheduler · Cloud Tasks · Workflows · Eventarc |
Two cross-cutting ideas hold it together:
- IAM is the unifier. Every API call is a permission check resolved as a
(principal, role, resource)binding. Get IAM right and everything else composes. - Pricing has two shapes. Serverless (Cloud Run, Cloud Run functions, BigQuery on-demand, Firestore, Gemini/Claude tokens) bills per use and scales to zero, with a real always-free tier. Provisioned (Compute Engine, GKE Standard nodes, Cloud SQL, Memorystore) bills for allocated capacity 24/7 whether or not it's busy. Choosing between them is cost optimisation.
Official Documentation
Getting started: SDK, auth, and your first project
Install the Google Cloud SDK (gcloud)
# macOS
brew install --cask google-cloud-sdk
# Linux / WSL
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Windows: download the installer
# https://cloud.google.com/sdk/docs/install
gcloud init # interactive: pick account + project + region
gcloud components install gke-gcloud-auth-plugin # if you'll use GKE
No install at all? Open Cloud Shell, a pre-authed
gcloudterminal in the browser.
The auth ladder (most to least preferred)
| Where the code runs | How it authenticates | Long-lived secret? |
|---|---|---|
| Your laptop | gcloud auth application-default login (ADC = your user) |
No |
| Cloud Run / GKE / Compute Engine | The attached service account (metadata server) | No |
| GitHub Actions | Workload Identity Federation, GitHub OIDC token → google-github-actions/auth v3 |
No |
| Vercel Functions | Workload Identity Federation, Vercel OIDC token → google-auth-library ExternalAccountClient |
No |
| Anything else, last resort | Service-account JSON key via GOOGLE_APPLICATION_CREDENTIALS |
Yes. Avoid; many orgs block key creation by policy |
gcloud auth login # you, for gcloud itself
gcloud auth application-default login # ADC, what the client libraries pick up
gcloud config set project my-project-id
gcloud config set run/region us-central1 # US-first default; africa-south1 for Kenya-targeted
Why ADC matters. Google's client libraries don't take a key argument; they walk the Application Default Credentials chain (the GOOGLE_APPLICATION_CREDENTIALS file, then gcloud user creds, then the attached service account). Authenticate once and every SDK call works locally with your identity. In production the attached service account (or a federated identity) is the identity, so there is no key file to leak.
Enable an API before you call it
Nearly every "permission/404" on a fresh project is a disabled API:
gcloud services enable run.googleapis.com artifactregistry.googleapis.com \
cloudbuild.googleapis.com secretmanager.googleapis.com aiplatform.googleapis.com \
iamcredentials.googleapis.com sts.googleapis.com
gcloud services list --enabled
Cost & billing model (the part that bites)
Figures are us-central1 / Tier-1 list prices from
cloud.google.com, reviewed 2026-10-20.africa-south1is a Tier-1 Cloud Run region (same rates as us-central1). Treat the Pricing Calculator as canonical.
Always-free tier (per billing account, every month; not the trial)
Source: Free cloud features and each product's pricing page.
| Product | Always-free monthly allowance |
|---|---|
| $300 trial credit | Spendable over 90 days (one-time, new accounts) |
| Compute Engine | 1 e2-micro VM (us-west1/us-central1/us-east1) + 30 GB-mo standard PD |
| Cloud Storage | 5 GB-mo regional (US regions) |
| Cloud Run, instance-based | 240,000 vCPU-s + 450,000 GiB-s |
| Cloud Run, request-based | 180,000 vCPU-s + 360,000 GiB-s + 2M requests |
| Cloud Run functions | Billed as Cloud Run (same free tier) |
| GKE | $74.40/month credit against the cluster fee (zonal and Autopilot clusters only), which covers one such cluster |
| BigQuery | 1 TiB queried + 10 GiB storage |
| Firestore | 1 GiB stored + 50k reads / 20k writes / 20k deletes per day |
| Pub/Sub | 10 GiB messages |
| Cloud Build | 2,500 build-minutes |
| Secret Manager | 6 active secret versions + 10,000 access ops + 3 rotation notifications |
| Cloud Logging | First 50 GiB ingested per project |
Headline rates (us-central1, Tier-1 list)
| Service | What you pay for | Rate |
|---|---|---|
| Cloud Run, instance-based | vCPU / memory for the whole instance lifetime | $0.000018 / vCPU-s · $0.000002 / GiB-s · no request fee |
| Cloud Run, request-based | vCPU / memory only while serving | $0.000024 / vCPU-s · $0.0000025 / GiB-s · $0.40 / M requests |
| idle min-instances (request-based) | $0.0000025 / vCPU-s · $0.0000025 / GiB-s | |
| GKE | cluster management | $0.10 / cluster / hour (+$0.50 in Extended-channel extended support) |
| Autopilot | per-second vCPU + memory + ephemeral storage requested by Pods | |
| BigQuery (on-demand) | bytes scanned | $6.25 / TiB (first 1 TiB/mo free) |
| active logical storage | $0.000031507 / GiB-hour ≈ $0.023 / GiB-mo (first 10 GiB free) | |
| Cloud Storage | Standard at-rest (US regional) | ~$0.020 / GB-mo (carried from 2026-08-23; region selector not machine-readable this pass) |
| Secret Manager | active versions / access ops | $0.06 / version-mo · $0.03 / 10k ops · $0.05 / rotation notification |
| Compute Engine | E2 VMs | billed 24/7; Spot 60–91% off, CUDs up to ~55% |
| Gemini / Claude tokens | per 1M tokens | see AI pricing |
Discount levers
- Spot VMs: 60–91% off on-demand, reclaimable on ~30 s notice. Batch / fault-tolerant work only.
- Committed Use Discounts: Cloud Run has its own CUDs; Compute Flexible CUDs apply across Compute Engine, GKE and Cloud Run.
- Batch / Flex for AI: Gemini and Claude batch inference is 50% off; Gemini also has Flex PayGo.
- Scale-to-zero: the biggest lever for spiky or low-traffic workloads. An idle Cloud Run service costs about nothing; an idle VM still bills.
Don't get surprised
# Budget + alert on day one
gcloud billing budgets create --billing-account=BILLING_ID \
--display-name="codeamani-monthly" \
--budget-amount=50USD \
--threshold-rule=percent=0.5 --threshold-rule=percent=0.9
Egress is the silent cost. Traffic to Google Cloud resources in the same region is free (Cloud Run → Cloud Run, Cloud Run → Cloud CDN / Load Balancing is free); cross-region and internet egress bill per GB.
Compute
flowchart TD
Q1{"Stateless container<br/>serving requests?"} -->|Yes| Q2{"One function<br/>covers it?"}
Q1 -->|No| Q3{"Need Kubernetes?"}
Q2 -->|Yes| F["Cloud Run functions"]
Q2 -->|No| R["Cloud Run"]
Q3 -->|Yes| G["GKE Autopilot"]
Q3 -->|No| C["Compute Engine VM"]
Choosing compute: the decision tree
Is it a stateless container that responds to requests/events?
├─ Yes → does a single function/endpoint cover it?
│ ├─ Yes → Cloud Run functions (smallest unit, event triggers)
│ └─ No → Cloud Run (any container, scale-to-zero, websockets, jobs)
└─ No → do you need Kubernetes / multi-container orchestration / service mesh?
├─ Yes → GKE (Autopilot first; Standard for node-level control)
└─ No → need a full OS, GPU, long-running daemon, or custom kernel?
├─ Yes → Compute Engine (VMs; Spot for batch)
└─ Legacy/managed PaaS → App Engine
Rule of thumb for codeAmani: Vercel stays the primary host for Next.js. Reach for Cloud Run when you need a container (long-running jobs, websockets, a Python service, a webhook receiver that must sit next to GCP data). Graduate to GKE only for real Kubernetes needs, and to Compute Engine only for stateful/GPU/long-running work.
Cloud Run: serverless containers (start here)
- Use case: APIs, webhook/callback receivers, background jobs, Python/AI services, self-hosted MCP servers.
- Implement: (see
examples/cloud-run-deploy.shand the keyless CI workflowexamples/github-actions-deploy-cloudrun.yml)
# Deploy straight from source; Cloud Build builds the container
gcloud run deploy my-api --source . --region us-central1 \
--service-account my-api-sa@PROJECT_ID.iam.gserviceaccount.com
# ...or from a prebuilt image in Artifact Registry (gcr.io Container Registry
# was shut down 2025-03-18; images live in REGION-docker.pkg.dev)
gcloud run deploy my-api \
--image us-central1-docker.pkg.dev/PROJECT_ID/app/my-api:latest --region us-central1
gcloud run services logs tail my-api --region us-central1
gcloud run jobs create nightly-recon \
--image us-central1-docker.pkg.dev/PROJECT_ID/app/recon:latest --region us-central1
gcloud run jobs execute nightly-recon --region us-central1
- Cost: two billing modes (rates above). Request-based (the default) charges CPU/memory only while a request is in flight, plus $0.40/M requests; best for spiky traffic. Instance-based keeps CPU allocated for the instance's whole life at lower per-second rates and no request fee; needed for background work after the response, and cheaper under steady load. Switch with
--no-cpu-throttling(instance-based) /--cpu-throttling(request-based) ongcloud run deployorservices update. Billing rounds up to 100 ms. - Gotcha: cold starts. For latency-sensitive endpoints (a Stripe webhook, or an M-Pesa STK callback on Kenya-targeted projects) set
--min-instances=1. In request-based mode an idle min instance bills at the idle rate (about $9.90/month for 1 vCPU + 0.5 GiB kept warm 730 h, before free tier). Requests rejected by IAM aren't billed.
Cloud Run functions: event-driven snippets
- Use case: "when X happens, run this": a Storage upload, a Pub/Sub message, an HTTP hook.
- Implement:
gcloud functions deploy thumb-maker \
--gen2 --runtime=nodejs24 --region=us-central1 \
--trigger-bucket=codeamani-uploads --entry-point=makeThumb
- Runtimes (2026-10-20):
nodejs24(deprecation 2028-04-30) is the current GA pick;nodejs22is supported until 2027-04-30;nodejs26is Preview. - Cost: runs on Cloud Run, so Cloud Run pricing and free tier apply.
- Gotcha: "Cloud Functions (2nd gen)" is branded Cloud Run functions and shares Cloud Run's runtime and limits.
GKE: managed Kubernetes
- Use case: you already speak Kubernetes and need multi-container orchestration, service mesh, or fine pod scheduling.
- Implement:
gcloud container clusters create-auto my-cluster --region us-central1 # Autopilot
gcloud container clusters get-credentials my-cluster --region us-central1
kubectl apply -f deployment.yaml
- Cost: $0.10/cluster/hour management fee on every cluster (~$73/month), minus a $74.40/month free-tier credit per billing account that applies only to zonal and Autopilot clusters. Autopilot bills per second for what Pods request; Standard bills the nodes whatever their utilisation.
- Gotcha: the credit covers one cluster's fee, not its compute. A second cluster, or any regional Standard cluster, pays the fee in full. Don't reach for GKE until orchestration earns it.
Compute Engine: virtual machines (the escape hatch)
gcloud compute instances create dev-box \
--zone=us-central1-a --machine-type=e2-small \
--image-family=debian-12 --image-project=debian-cloud --tags=http-server
gcloud compute ssh dev-box --zone=us-central1-a
gcloud compute instances stop dev-box --zone=us-central1-a # stop to save money
- Cost: billed 24/7 while running; persistent disk bills per GB-month even when stopped.
- Gotcha: open SSH explicitly on non-default networks (
gcloud compute firewall-rules create allow-ssh --allow tcp:22), or better, use IAP TCP forwarding.
Databases
| Service | Shape | Reach for it when… |
|---|---|---|
| Cloud SQL | Managed Postgres / MySQL / SQL Server | You want relational SQL with zero ops. (codeAmani's default Postgres is Neon/Supabase; Cloud SQL is for workloads that must live inside GCP.) |
| AlloyDB | Postgres-compatible, HTAP | Heavy Postgres needing high throughput + analytics on the same data. |
| Spanner | Globally distributed relational | Horizontal scale and strong consistency. |
| Firestore | Serverless document DB | Mobile/web apps, real-time listeners, scale-to-zero, offline sync. |
| Bigtable | Wide-column NoSQL | Massive low-latency key/value (time series, IoT). |
| Memorystore | Managed Redis / Valkey | Caching, sessions, rate-limit counters. |
| BigQuery | Serverless analytics warehouse | Analytics/BI/petabyte SQL. Not an app DB. |
Cloud SQL
gcloud sql instances create app-db --database-version=POSTGRES_16 \
--tier=db-f1-micro --region=us-central1
gcloud sql databases create app --instance=app-db
# From Cloud Run, connect via the built-in Cloud SQL connector (no public IP needed):
gcloud run deploy my-api --add-cloudsql-instances PROJECT_ID:us-central1:app-db
- Cost: provisioned; vCPU + RAM + storage 24/7, HA doubles it, no scale-to-zero. For low-traffic apps a small instance can dwarf your Cloud Run bill.
Firestore
import { Firestore } from "@google-cloud/firestore"; // 9.3.1
const db = new Firestore(); // ADC / attached service account
// create() fails with gRPC ALREADY_EXISTS (code 6) if the doc exists: a free idempotency key.
export async function recordEventOnce(eventId: string): Promise<boolean> {
try {
await db.collection("stripe_events").doc(eventId).create({ status: "RECEIVED" });
return true; // first delivery: process it
} catch (err) {
if ((err as { code?: number }).code === 6) return false; // duplicate delivery: skip
throw err;
}
}
- Cost: per operation (reads / writes / deletes) + stored GiB + egress; free 50k reads / 20k writes / 20k deletes per day. Chatty real-time listeners rack up reads, so model fewer, denormalised documents.
- Firebase: Firestore is the Firebase database. Server code uses
firebase-admin(14.5.0) or@google-cloud/firestorewith ADC; client apps use thefirebaseJS SDK (13.0.0) with Security Rules. "Vertex AI in Firebase" is now "Gemini Enterprise Agent Platform in Firebase".
Storage
Cloud Storage: object store
- Use case: user uploads, build artefacts, ML data, backups, staging buckets.
- Implement: (typed helpers in
examples/storage-upload.ts,@google-cloud/storage8.4.0, Node ≥ 22)
gcloud storage buckets create gs://codeamani-uploads --location=us-central1 \
--uniform-bucket-level-access --public-access-prevention
gcloud storage cp ./file.pdf gs://codeamani-uploads/
gcloud storage sign-url gs://codeamani-uploads/file.pdf --duration=15m \
--impersonate-service-account=signer@PROJECT_ID.iam.gserviceaccount.com
- Cost: Standard ~$0.020/GB-mo in US regions. Lifecycle rules tier cold data to Nearline → Coldline → Archive (cheaper to store, with retrieval fees and minimum durations). Internet egress is billed.
- Gotcha: use V4 signed URLs for browser up/downloads so you never ship credentials to the client. Signing without a key file needs
roles/iam.serviceAccountTokenCreatoron the signing service account.
AI / ML on Gemini Enterprise Agent Platform
Agent Platform (formerly Vertex AI) is Google Cloud's enterprise AI surface: Gemini models, partner models including Claude, open models (Gemma 4, DeepSeek, Llama) via Model Garden, plus Agent Runtime, RAG Engine and Vector Search. Choose it over the Gemini Developer API (AI Studio guide) or the Claude API (anthropic guide) when you need IAM instead of API keys, data residency (us/eu), CMEK, VPC Service Controls, one GCP invoice, or committed spend.
Gemini models (verified 2026-10-20)
| Model ID | Stage | Use for | Locations |
|---|---|---|---|
gemini-4-argon |
GA (2026-10-13) | Frontier "deep work": hard coding, legal/finance reasoning. Unified 1,048,576-token in+out limit; thinking levels LOW/MEDIUM (default)/HIGH; sampling params ignored |
global, us, eu |
gemini-3.8-flash |
GA (2026-09-02) | Default workhorse: agents, coding, multimodal. 1M context, 65,536 output | global, us, eu |
gemini-3.5-flash |
GA (2026-05-19) | Google's alternative replacement for 2.5 Flash/Pro | global + non-global |
gemini-3.5-flash-lite |
GA (2026-07-21) | Cheap high-volume classification, routing, extraction | global + non-global |
gemini-3.1-flash-lite |
GA (2026-05-07) | Cheapest text model | global + non-global |
gemini-3.1-pro-preview |
Public preview | Reasoning-first; don't pin in production | global |
gemini-2.5-pro / -flash / -flash-lite |
Retired 2026-10-20 on Google Cloud | Migrate now | — |
There is no africa-south1 location for any Gemini or Claude model; africa-south1 on Agent Platform covers custom-model training/inference and Model Registry only.
Calling Gemini (Google Gen AI SDK)
@google/genai 2.30.0 (Node ≥ 20) / google-genai 2.31.0 (Python). The legacy vertexai.generative_models modules were removed 2026-06-24 and @google-cloud/vertexai is deprecated in the docs (npm still serves 1.12.0); don't use them. Runnable file: examples/gemini-agent-platform.mts.
import { GoogleGenAI, ThinkingLevel } from "@google/genai";
const ai = new GoogleGenAI({
vertexai: true, // Google Cloud (IAM). Omit + pass apiKey for AI Studio.
project: process.env.GOOGLE_CLOUD_PROJECT,
location: "global", // Gemini 3.x/4: global | us | eu
});
const res = await ai.models.generateContent({
model: "gemini-3.8-flash",
contents: "Andika salamu fupi kwa Kiswahili.",
config: { maxOutputTokens: 512, thinkingConfig: { thinkingLevel: ThinkingLevel.LOW } },
});
console.log(res.text);
# pip install google-genai==2.31.0
from google import genai
client = genai.Client(vertexai=True, project="PROJECT_ID", location="global")
resp = client.models.generate_content(model="gemini-3.8-flash", contents="Hello")
print(resp.text)
The SDK also reads GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION from the environment (see the settings table below). Gemini 4 Argon long decodes (output past 65,536 tokens via continuation_token) only work on the v1beta1 API, which the Gen AI SDK uses by default.
Claude on Google Cloud
Claude models are served as managed APIs from Model Garden and billed on your Google Cloud invoice. No Anthropic API key is involved; IAM (roles/aiplatform.user) is the gate. Runnable file: examples/claude-on-google-cloud.mts.
| Model ID | Released on Google Cloud | Context / max output | Global endpoint quota (default) |
|---|---|---|---|
claude-fable-5-1 |
2026-09-01 | 1M / 128K | needs the Advanced AI Safety Addendum accepted in Model Garden |
claude-opus-5-5 (codeAmani default) |
2026-09-22 | 1M / 128K | 2,000 QPM · 20M input TPM · 2M output TPM |
claude-sonnet-5-5 |
2026-09-28 | 1M / 128K | 2,500 QPM · 25M input TPM |
claude-haiku-5-5 |
2026-10-07 | 1M / 128K | 3,000 QPM · 30M input TPM |
IDs match the anthropic guide: bare IDs, no anthropic. prefix (that is Bedrock), no date suffix. Older Opus 5 / 4.8 / 4.7 / 4.6 / 4.5, Sonnet 5 / 4.6 / 4.5 and Haiku 4.5 are still listed.
Endpoints. global (cheapest, highest quota, request may be served from any supported region) · us / eu multi-region (aiplatform.us.rep.googleapis.com / aiplatform.eu.rep.googleapis.com; data stays in that geography; Claude 4.7 and later) · regional such as us-east5, europe-west1, asia-southeast1. Non-global endpoints cost 10% more. Prompt caching works on global and multi-region; Provisioned Throughput doesn't. Orgs can block the global endpoint with constraints/gcp.restrictEndpointUsage.
# One-time: enable the API, then click Enable on the Claude model card in Model Garden
gcloud services enable aiplatform.googleapis.com
npm i @anthropic-ai/vertex-sdk@0.21.0 # pulls @anthropic-ai/sdk 0.135.x
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";
const claude = new AnthropicVertex({ projectId: process.env.GOOGLE_CLOUD_PROJECT, region: "global" });
const msg = await claude.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Review this webhook handler for idempotency bugs." }],
});
# pip install "anthropic[vertex]==1.15.0"
from anthropic import AnthropicVertex
client = AnthropicVertex(project_id="PROJECT_ID", region="global")
msg = client.messages.create(model="claude-haiku-5-5", max_tokens=256,
messages=[{"role": "user", "content": "Classify: refund request?"}])
Google lists computer use, web search, batch, prompt caching, function calling, count tokens and the memory tool as supported for Opus 5.5. Platform differences vs the Claude API (from the anthropic guide): server-side model fallbacks aren't available (use the SDK's client-side fallback middleware), and web search is the basic web_search_20250305 tool. Raw REST uses :rawPredict / :streamRawPredict with "anthropic_version": "vertex-2023-10-16" in the body.
AI pricing (per 1M tokens, global endpoint)
Source: Agent Platform pricing, read 2026-10-20. Non-global endpoints are +10% for Gemini 3+ and Claude. Batch is 50% off.
| Model | Input | Output | Notes |
|---|---|---|---|
gemini-4-argon |
$2.00 → $4.00 | $10.00 → $20.00 | promo through 2026-11-30, list from 2026-12-01 |
gemini-3.8-flash |
$0.75 → $1.50 | $3.75 → $7.50 | promo through 2026-12-31, list from 2027-01-01 (same for 3.7 / 3.6 Flash) |
gemini-3.5-flash |
$1.50 | $9.00 | |
gemini-3.5-flash-lite |
$0.30 | $2.50 | |
gemini-3.1-flash-lite |
$0.25 | $1.50 | text/image/video input |
claude-fable-5-1 |
$10.00 | $50.00 | |
claude-opus-5-5 |
$4.00 | $20.00 | cache hit $0.20 |
claude-sonnet-5-5 |
$2.00 | $10.00 | cache hit $0.10 |
claude-haiku-5-5 |
$0.10 / $0.50 | $0.50 / $2.50 | ≤100K / >100K input tokens |
Grounding with Google Search on Gemini 3/4: 5,000 queries/month free, then $14 per 1,000.
Agent Runtime (formerly Agent Engine)
Managed hosting for agents built with ADK, LangGraph, LlamaIndex or A2A, with Memory Bank (long-term memory) and Sessions. Google's quickstart now drives it with agents-cli (agents-cli scaffold enhance --deployment-target cloud_run, agents-cli deploy). For a low-volume codeAmani agent, a Cloud Run service calling Gemini or Claude directly is usually cheaper and simpler; reach for Agent Runtime when you need managed memory/sessions. Not available in africa-south1. Docs: https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/runtime
Eventing, scheduling & orchestration
| Service | Use case | One-liner |
|---|---|---|
| Pub/Sub | Async messaging / fan-out | gcloud pubsub topics create payments |
| Eventarc | Route GCP events (e.g. a GCS upload) to Cloud Run | Trigger services from many event sources |
| Cloud Tasks | Reliable async task queues with rate limits and retries | Deferred work, outbound webhooks |
| Cloud Scheduler | Cron as a service | gcloud scheduler jobs create http nightly --schedule="0 2 * * *" --uri=URL |
| Workflows | Serverless orchestration of API/service steps | YAML state machine |
- Gotcha: Pub/Sub is at-least-once, so make subscribers idempotent (the same dedup discipline as Stripe webhooks).
DevOps: build, registry, deploy, CI/CD
- Cloud Build: CI/CD; free 2,500 build-minutes/month.
- Artifact Registry: container + package registry. Container Registry (
gcr.io) shut down 2025-03-18; push toREGION-docker.pkg.dev. Google-ownedgcr.io/cloud-builders/*images still work. - Cloud Deploy: managed progressive delivery for Cloud Run / GKE.
- GitHub Actions:
google-github-actions/auth@v3+deploy-cloudrun@v3(both run onnode24), keyless via WIF. Full workflow with SHA-pinned actions:examples/github-actions-deploy-cloudrun.yml.
# cloudbuild.yaml: build, test, push, deploy to Cloud Run
steps:
- { name: node:24, entrypoint: npm, args: [ci] }
- { name: node:24, entrypoint: npm, args: [test] }
- { name: gcr.io/cloud-builders/docker,
args: [build, -t, "$_REGION-docker.pkg.dev/$PROJECT_ID/app/$_SVC:$COMMIT_SHA", .] }
- { name: gcr.io/cloud-builders/docker,
args: [push, "$_REGION-docker.pkg.dev/$PROJECT_ID/app/$_SVC:$COMMIT_SHA"] }
- { name: gcr.io/google.com/cloudsdktool/cloud-sdk, entrypoint: gcloud,
args: [run, deploy, "$_SVC", "--image=$_REGION-docker.pkg.dev/$PROJECT_ID/app/$_SVC:$COMMIT_SHA",
"--region=$_REGION"] }
substitutions: { _SVC: my-api, _REGION: us-central1 }
options: { logging: CLOUD_LOGGING_ONLY }
Networking (the essentials)
| Service | What it does |
|---|---|
| VPC | Private software-defined network; subnets are regional, the VPC is global |
| Cloud Load Balancing | Global anycast L7/L4 load balancer |
| Cloud CDN | Edge caching in front of the load balancer |
| Cloud Armor | WAF + DDoS protection |
| Cloud DNS | Managed authoritative DNS (codeAmani domains stay on Porkbun DNS unless a project needs Cloud DNS) |
Keep DB, cache and compute in the same region; cross-region traffic bills per GB.
Security & Identity
IAM: every call is a permission check
| Concept | Meaning |
|---|---|
| Principal | Who: user, group, service account, or federated identity (principal:// / principalSet://) |
| Role | A permission bundle, e.g. roles/run.invoker, roles/aiplatform.user |
| Binding | A (principal, role, resource) triple, the grant itself |
gcloud projects get-iam-policy PROJECT_ID
gcloud run services add-iam-policy-binding my-api --region=us-central1 \
--member="serviceAccount:caller@PROJECT_ID.iam.gserviceaccount.com" --role="roles/run.invoker"
Least privilege: predefined roles over roles/owner; bind at the narrowest scope (one bucket, one service, one secret); one service account per service. IAM changes can take a minute or more to propagate.
Secret Manager: runtime secrets
printf '%s' "$VALUE_FROM_VAULT" | gcloud secrets create STRIPE_SECRET_KEY --data-file=-
gcloud secrets add-iam-policy-binding STRIPE_SECRET_KEY \
--member="serviceAccount:my-api-sa@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
# Mount into Cloud Run (never bake secrets into images or plain env vars):
gcloud run deploy my-api --update-secrets=STRIPE_SECRET_KEY=STRIPE_SECRET_KEY:latest
Keyless auth: Workload Identity Federation
WIF trades an external OIDC token (GitHub, Vercel) for a short-lived Google access token through STS, optionally impersonating a service account. There is no JSON key to store, rotate or leak.
From GitHub Actions (from the google-github-actions/auth v3 README):
gcloud iam workload-identity-pools create github --project=PROJECT_ID \
--location=global --display-name="GitHub Actions"
gcloud iam workload-identity-pools providers create-oidc codeamani-repos \
--project=PROJECT_ID --location=global --workload-identity-pool=github \
--issuer-uri="https://token.actions.githubusercontent.com" \
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository,attribute.repository_owner=assertion.repository_owner" \
--attribute-condition="assertion.repository_owner == 'codeAmani-Labs'"
gcloud iam service-accounts add-iam-policy-binding deployer@PROJECT_ID.iam.gserviceaccount.com \
--role=roles/iam.workloadIdentityUser \
--member="principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github/attribute.repository/codeAmani-Labs/REPO"
permissions: { contents: read, id-token: write }
steps:
- uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3
with:
workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }}
service_account: ${{ vars.GCP_DEPLOYER_SA }}
The --attribute-condition is mandatory in practice: without it, any GitHub repo could present a token to your pool.
From Vercel (per Vercel's GCP OIDC guide): create pool vercel with an OIDC provider whose issuer is https://oidc.vercel.com/<TEAM_SLUG> (team issuer mode) and mapping google.subject = assertion.sub. Grant the service account to principal://iam.googleapis.com/projects/<NUM>/locations/global/workloadIdentityPools/vercel/subject/owner:<TEAM>:project:<PROJECT>:environment:production, one principal per project + environment. In code:
import { getVercelOidcToken } from "@vercel/oidc"; // 4.0.1
import { ExternalAccountClient } from "google-auth-library"; // 11.3.1
import { Storage } from "@google-cloud/storage"; // 8.4.0
const authClient = ExternalAccountClient.fromJSON({
type: "external_account",
audience: `//iam.googleapis.com/projects/${process.env.GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${process.env.GCP_WORKLOAD_IDENTITY_POOL_ID}/providers/${process.env.GCP_WORKLOAD_IDENTITY_POOL_PROVIDER_ID}`,
subject_token_type: "urn:ietf:params:oauth:token-type:jwt",
token_url: "https://sts.googleapis.com/v1/token",
service_account_impersonation_url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${process.env.GCP_SERVICE_ACCOUNT_EMAIL}:generateAccessToken`,
subject_token_supplier: { getSubjectToken: () => getVercelOidcToken() },
});
if (!authClient) throw new Error("WIF config invalid");
const storage = new Storage({ projectId: process.env.GCP_PROJECT_ID, authClient });
Full typed version with an upload route: examples/vercel-wif.ts. Version gotcha: @google/genai 2.30.0 and @anthropic-ai/vertex-sdk 0.21.0 still depend on google-auth-library 10.x, so an 11.x client won't type-check as their authClient. Pass accessToken from authClient.getAccessToken() to AnthropicVertex, or pin google-auth-library@10.9.1 in AI-only routes.
Cloud KMS
Customer-managed encryption keys (CMEK) for data you must control at rest. Gemini 3.8 Flash and Gemini 4 Argon list CMEK, data residency and VPC-SC for online, batch and context-caching requests on Agent Platform.
Observability
- Cloud Logging: centralised logs; free 50 GiB/project/month.
- Cloud Monitoring: metrics, dashboards, uptime checks, alerting.
- Cloud Trace / Error Reporting: distributed traces and exception grouping. (codeAmani's app-level error tracking stays on Sentry.)
gcloud logging read 'resource.type=cloud_run_revision severity>=ERROR' --limit 20 --freshness=1h
Cloud Shell (the browser terminal)
A free, pre-authed Debian VM at shell.cloud.google.com with gcloud, bq, kubectl, docker, Node and Python, and 5 GB persistent $HOME.
gcloud cloud-shell ssh
gcloud cloud-shell ssh --command "gcloud run services list"
Only $HOME persists.
Claude Code integration
gcloud via the Bash tool (most reliable)
// .claude/settings.json
{ "permissions": { "allow": ["Bash(gcloud:*)", "Bash(bq:*)"] } }
Google Cloud remote MCP servers (first-party)
Google now hosts remote MCP servers on Google infrastructure, one per product, e.g. Cloud Run https://run.googleapis.com/mcp, Firestore https://firestore.googleapis.com/mcp, IAM https://iam.googleapis.com/mcp, Cloud Logging https://logging.googleapis.com/mcp, GKE https://container.googleapis.com/mcp, and the gcloud CLI server https://cloudcli.googleapis.com/mcp (Preview). Full list: https://docs.cloud.google.com/mcp/supported-products. They support MCP spec 2026-07-28.
Setup per Google's docs: enable the product API, grant the caller roles/mcp.toolUser on the project, then (for Claude Code / claude.ai / Claude Desktop) create a Web application OAuth client in Google Auth Platform with redirect URI https://claude.ai/api/mcp/auth_callback and add the server as a custom connector with that client ID and secret. The OAuth client secret is a real secret: keep it in the vault. Use toolset endpoints where a server offers them, to keep the tool list small.
Slash command: analyze Cloud Run logs
<!-- .claude/commands/gcp-logs.md -->
Analyze recent Cloud Run logs for $ARGUMENTS.
Run: gcloud logging read 'resource.type=cloud_run_revision AND resource.labels.service_name=$ARGUMENTS AND severity>=WARNING' --limit 50 --freshness=1h
Summarise errors, high-latency requests, and crash loops with root causes + fixes.
Settings (not secrets)
None of these are credentials, so they belong in project settings / Vercel env config, not the secrets vault. In the keyless setups above there is no Google secret at all.
| Variable | Example | Used by |
|---|---|---|
GOOGLE_CLOUD_PROJECT |
my-project-123456 |
Client libraries, Gen AI SDK |
GOOGLE_CLOUD_LOCATION |
global |
Gen AI SDK (Gemini 3.x/4: global, us, eu) |
GOOGLE_GENAI_USE_VERTEXAI |
true |
Gen AI SDK: route to Google Cloud instead of AI Studio |
CLOUD_ML_REGION |
global |
@anthropic-ai/vertex-sdk default region |
GCP_PROJECT_ID / GCP_PROJECT_NUMBER |
my-project-123456 / 1234567890 |
Vercel WIF |
GCP_SERVICE_ACCOUNT_EMAIL |
vercel@my-project-123456.iam.gserviceaccount.com |
Vercel WIF |
GCP_WORKLOAD_IDENTITY_POOL_ID / ..._PROVIDER_ID |
vercel / vercel |
Vercel WIF |
GOOGLE_APPLICATION_CREDENTIALS |
path to a key file | Last resort only. The file it points at is a secret; never commit it |
Official learning resources
| Resource | What it is | URL |
|---|---|---|
| Cloud Skills Boost | Google's courses + hands-on labs | https://www.cloudskillsboost.google/ |
| Google Cloud Codelabs | Build-along tutorials | https://codelabs.developers.google.com/ |
| Architecture Center | Reference architectures | https://cloud.google.com/architecture |
| Well-Architected Framework | Reliability, security, cost, ops pillars | https://cloud.google.com/architecture/framework |
| Certifications | Associate Cloud Engineer → Professional tracks | https://cloud.google.com/learn/certification |
| Free Tier + $300 trial | Build for real at near-zero cost | https://cloud.google.com/free |
| gcloud cheat sheet | One-pager of essential commands | https://cloud.google.com/sdk/docs/cheatsheet |
Suggested path for a codeAmani dev: Free Tier sign-up → deploy a container to Cloud Run → wire Firestore + Secret Manager → add the keyless GitHub Actions deploy → call Gemini 3.8 Flash and Claude Opus 5.5 through Agent Platform → read the cost and security pillars of the Well-Architected Framework.
Troubleshooting
| Issue | Fix |
|---|---|
gcloud: command not found |
Run gcloud init after install; restart the shell |
403 / API not enabled |
gcloud services enable <api>.googleapis.com, then retry |
| ADC not configured | gcloud auth application-default login |
403 permission denied (API enabled) |
Grant the role at the narrowest scope |
404 model not found for gemini-2.5-* |
Retired 2026-10-20 → gemini-3.8-flash / gemini-3.5-flash-lite |
Gemini 3.x/4 404 in us-central1 |
Those models live on global, us, eu only; set location: "global" |
Claude 403 / "not enabled" |
Click Enable on the model card in Model Garden; needs Consumer Procurement Entitlement Manager to accept terms |
| Claude 429s on a regional endpoint | Switch to region: "global" (higher default quota, 10% cheaper) |
WIF: unauthorized_client / invalid_grant |
Attribute condition or principal subject doesn't match the token's repository / Vercel sub (owner:TEAM:project:PROJECT:environment:ENV) |
| WIF works but API calls 403 | The impersonated SA lacks the resource role, or the principal lacks roles/iam.workloadIdentityUser on the SA |
| Cloud Run cold starts | --min-instances=1 for latency-sensitive endpoints |
| Surprise bill | Egress, an always-on VM / Cloud SQL, or a second GKE cluster; set a budget alert on day one |
codeAmani notes
- Where GCP fits. Vercel is the primary app host and Neon/Supabase the default databases. Reach for GCP for Cloud Run containers, Cloud Storage, Secret Manager for GCP-hosted services, BigQuery analytics, and Agent Platform when a project needs Gemini or Claude under Google Cloud IAM, residency or billing.
- Secrets stay server-side, and ideally don't exist. Service-account JSON keys are radioactive. Use ADC locally, the attached service account on Cloud Run, and Workload Identity Federation from GitHub Actions and Vercel. Mount Secret Manager versions into Cloud Run with
--update-secretsinstead of baking values into env vars or images. - AI routing. Claude stays the primary model per codeAmani routing. Call it through the Claude API by default (see the anthropic guide); use Claude on Google Cloud when a project must keep traffic inside Google Cloud IAM / residency / billing, or wants one invoice with Gemini. Use Gemini 3.8 Flash via Agent Platform when you need IAM-gated Gemini; use AI Studio for quick prototypes. Prefer the
globalendpoint unless residency requiresus/eu(+10%). - Payments. Stripe is the default rail. Host a Stripe webhook on Cloud Run only if the service already lives in GCP; verify the Stripe signature, and store the event ID in Firestore with
create()for idempotency. - Kenya-targeted projects (per-project).
africa-south1(Johannesburg) is the nearest GCP region to Nairobi and a Tier-1 price region for Cloud Run; Firestore, Cloud SQL, BigQuery, Secret Manager, GKE and Cloud Storage run there. No Gemini or Claude endpoint exists in Africa: call AI onglobal, oreuif you need a residency story for KDPA. Host the Daraja callback on Cloud Run inafrica-south1with--min-instances=1, and storeCheckoutRequestIDin Firestore as the dedup key. - Lean SaaS cost. Cloud Run (scale-to-zero) + Firestore (free daily tier) + Cloud Storage + Secret Manager keeps a low-traffic product inside or near the always-free tier. Avoid an always-on Cloud SQL, or a second GKE cluster, until traffic justifies 24/7 spend.
Official docs:
- https://cloud.google.com/docs
- https://cloud.google.com/sdk/gcloud
- https://cloud.google.com/products/calculator
- https://cloud.google.com/free/docs/free-cloud-features
- https://cloud.google.com/run/docs
- https://cloud.google.com/run/pricing
- https://cloud.google.com/compute/docs
- https://cloud.google.com/kubernetes-engine/docs
- https://cloud.google.com/bigquery/docs
- https://cloud.google.com/sql/docs
- https://cloud.google.com/firestore/docs
- https://cloud.google.com/storage/docs
- https://docs.cloud.google.com/gemini-enterprise-agent-platform
- https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/google-models
- https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/partner-models/claude
- https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/pricing
- https://cloud.google.com/iam/docs/workload-identity-federation
- https://docs.cloud.google.com/mcp/supported-products
- https://cloud.google.com/iam/docs
- https://cloud.google.com/architecture
- https://www.cloudskillsboost.google/