Claude

Claude on Vertex AI examples for runs, storage, multimodal input, knowledge, memory, caching, thinking, structured output, and tools.

The source uses claude-sonnet-4@20250514, which Anthropic lists as deprecated on Google Cloud. Google's Sonnet 4 card does not establish a completed retirement. For a new deployment, choose a current model and its supported settings, such as Sonnet 4.6. Provider availability and lifecycle dates can differ from the direct Anthropic API.

ExampleDescription
Vertex AI BasicRun Claude Sonnet 4 on Vertex AI with sync, streaming, and async calls.
Vertex AI Basic With TimeoutSet a five-second request timeout on Claude Sonnet 4 running on Vertex AI.
BetasPass a beta option to Claude on Vertex AI and inspect the SDK’s known beta names.
DBPersist session history in SQLite so a Vertex AI Claude agent can answer follow-ups.
Vertex AI Image Input BytesSend a downloaded image as bytes to Claude on Vertex AI and search the web about it.
Vertex AI Image Input URLPass an image URL to Claude on Vertex AI and search the web for more context.
KnowledgeAnswer questions from a PgVector knowledge base with Claude on Vertex AI.
MemoryStore personalized memories and session summaries with Claude on Vertex AI using PostgreSQL.
Vertex AI PDF Input BytesSummarize a PDF passed as raw bytes to Claude Sonnet 4 on Vertex AI.
Vertex AI PDF Input LocalSummarize a local PDF file passed by path to Claude Sonnet 4 on Vertex AI.
Prompt CachingMark a reusable system prompt for caching and inspect Claude’s cache usage on Vertex AI.
Vertex AI Structured OutputRequest JSON from Claude on Vertex AI and validate it locally as a MovieScript.
Vertex AI ThinkingEnable extended thinking with a 1024-token budget on Claude Sonnet 4 via Vertex AI.
Tool UseGive Claude on Vertex AI web search tools and run it sync, streaming, and async.
Adaptive ThinkingUse adaptive thinking with effort levels to control reasoning depth on Claude VertexAI.