#!/usr/bin/env python3 # 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) # Install: pip install -U "anthropic[vertex]" # Auth: Google Application Default Credentials (`gcloud auth application-default login`). # Env: ANTHROPIC_VERTEX_PROJECT_ID, CLOUD_ML_REGION ("global" recommended; "us"/"eu" multi-region; or e.g. us-east5). import os from anthropic import AnthropicVertex client = AnthropicVertex( project_id=os.environ["ANTHROPIC_VERTEX_PROJECT_ID"], region=os.environ.get("CLOUD_ML_REGION", "global"), ) # On Google Cloud the model goes in the URL and anthropic_version ("vertex-2023-10-16") in the body; the SDK handles both. message = client.messages.create( model="claude-haiku-4-5@20251001", # cheapest Haiku 4.5 id on Google Cloud (date separated with @) max_tokens=8, messages=[{"role": "user", "content": "Reply with OK."}], ) print(next(block.text for block in message.content if block.type == "text"))