#!/usr/bin/env bash # STATUS: UNVERIFIED — no cloud credentials in this atlas; snippet follows official docs verbatim-ish # Source: https://platform.claude.com/docs/en/build-with-claude/claude-on-vertex-ai (retrieved 2026-09-18) # Requires gcloud with Application Default Credentials. No secrets in this file. set -eo pipefail PROJECT_ID="${ANTHROPIC_VERTEX_PROJECT_ID:?set ANTHROPIC_VERTEX_PROJECT_ID}" LOCATION="${CLOUD_ML_REGION:-global}" MODEL_ID="claude-haiku-4-5@20251001" # cheapest Haiku 4.5 id on Google Cloud # Host depends on the endpoint type: # global -> https://aiplatform.googleapis.com (locations/global) # us | eu -> https://aiplatform.${LOCATION}.rep.googleapis.com (multi-region, +10%) # us-east5 ... -> https://${LOCATION}-aiplatform.googleapis.com (regional, +10%; Sonnet 4.6 and earlier) case "$LOCATION" in global) HOST="https://aiplatform.googleapis.com" ;; us|eu) HOST="https://aiplatform.${LOCATION}.rep.googleapis.com" ;; *) HOST="https://${LOCATION}-aiplatform.googleapis.com" ;; esac # model is in the URL, anthropic_version is in the body (not a header). Streaming uses :streamRawPredict. curl -sS "${HOST}/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/anthropic/models/${MODEL_ID}:rawPredict" \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -d '{ "anthropic_version": "vertex-2023-10-16", "max_tokens": 8, "messages": [{"role": "user", "content": "Reply with OK."}] }' echo