Skip to content

Build With Claude Claude On Vertex Ai

Updated 4 days ago

export const ModelId = ({children, style = {}}) => { const copiedNotice = 'Copied!'; const handleClick = e => { const element = e.currentTarget; const textSpan = element.querySelector('.model-id-text'); const copiedSpan = element.querySelector('.model-id-copied'); navigator.clipboard.writeText(children).then(() => { textSpan.style.opacity = '0'; copiedSpan.style.opacity = '1'; element.style.backgroundColor = '#d4edda'; element.style.borderColor = '#c3e6cb'; setTimeout(() => { textSpan.style.opacity = '1'; copiedSpan.style.opacity = '0'; element.style.backgroundColor = '#f5f5f5'; element.style.borderColor = 'transparent'; }, 2000); }).catch(error => { console.error('Failed to copy:', error); }); }; const handleMouseEnter = e => { const element = e.currentTarget; const copiedSpan = element.querySelector('.model-id-copied'); const tooltip = element.querySelector('.copy-tooltip'); if (tooltip && copiedSpan.style.opacity !== '1') { tooltip.style.opacity = '1'; } element.style.backgroundColor = '#e8e8e8'; element.style.borderColor = '#d0d0d0'; }; const handleMouseLeave = e => { const element = e.currentTarget; const copiedSpan = element.querySelector('.model-id-copied'); const tooltip = element.querySelector('.copy-tooltip'); if (tooltip) { tooltip.style.opacity = '0'; } if (copiedSpan.style.opacity !== '1') { element.style.backgroundColor = '#f5f5f5'; element.style.borderColor = 'transparent'; } }; const defaultStyle = { cursor: 'pointer', position: 'relative', transition: 'all 0.2s ease', display: 'inline-block', userSelect: 'none', backgroundColor: '#f5f5f5', padding: '2px 4px', borderRadius: '4px', fontFamily: 'Monaco, Consolas, "Courier New", monospace', fontSize: '0.75em', border: '1px solid transparent', ...style }; return <span onClick={handleClick} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} style={defaultStyle}> <span className="model-id-text" style={{ transition: 'opacity 0.1s ease' }}> {children} </span> <span className="model-id-copied" style={{ position: 'absolute', top: '2px', left: '4px', right: '4px', opacity: '0', transition: 'opacity 0.1s ease', color: '#155724' }}> {copiedNotice} </span> </span>; };

The Vertex API for accessing Claude is nearly-identical to the Messages API and supports all of the same options, with two key differences:

  • In Vertex, model is not passed in the request body. Instead, it is specified in the Google Cloud endpoint URL.
  • In Vertex, anthropic_version is passed in the request body (rather than as a header), and must be set to the value vertex-2023-10-16.

Vertex is also supported by Anthropic's official client SDKs. This guide will walk you through the process of making a request to Claude on Vertex AI in either Python or TypeScript.

Note that this guide assumes you have already have a GCP project that is able to use Vertex AI. See using the Claude 3 models from Anthropic for more information on the setup required, as well as a full walkthrough.

Install an SDK for accessing Vertex AI

First, install Anthropic's client SDK for your language of choice.

See our client SDKs and the official Vertex AI docs for more details.

Activity logging

Vertex provides a request-response logging service that allows customers to log the prompts and completions associated with your usage.

Anthropic recommends that you log your activity on at least a 30-day rolling basis in order to understand your activity and investigate any potential misuse.

Note: Turning on this service does not give Google or Anthropic any access to your content.

Feature support

You can find all the features currently supported on Vertex here.

Global vs regional endpoints

Starting with Claude Sonnet 4.5 and all future models, Google Vertex AI offers two endpoint types:

  • Global endpoints: Dynamic routing for maximum availability
  • Regional endpoints: Guaranteed data routing through specific geographic regions

Regional endpoints include a 10% pricing premium over global endpoints.

Note: This applies to Claude Sonnet 4.5 and future models only. Older models (Claude Sonnet 4, Opus 4, and earlier) maintain their existing pricing structures.

When to use each option

Global endpoints (recommended):

  • Provide maximum availability and uptime
  • Dynamically route requests to regions with available capacity
  • No pricing premium
  • Best for applications where data residency is flexible
  • Only supports pay-as-you-go traffic (provisioned throughput requires regional endpoints)

Regional endpoints:

  • Route traffic through specific geographic regions
  • Required for data residency and compliance requirements
  • Support both pay-as-you-go and provisioned throughput
  • 10% pricing premium reflects infrastructure costs for dedicated regional capacity

Implementation

Using global endpoints (recommended):

Set the region parameter to "global" when initializing the client:

Additional resources