Google Vertex AI in Practice

Calling Claude on Vertex AI from Java

Java shops can reach Claude on Vertex AI the same way they reach any Google Cloud API: Application Default Credentials plus an authenticated HTTPS request. Here's the shape of a working integration.

Claude 3P 101 · Updated July 2026 · Unofficial guide

Anthropic's official SDK documentation for Vertex AI leads with Python and TypeScript. Java teams have two workable paths: an Anthropic Java library, if one fits your build — check the official Vertex AI documentation for current library options and their exact Maven coordinates, since this guide won't guess artifact names — or a plain authenticated REST call, which works with nothing more than a standard HTTP client and Google's auth library. Because the second path is fully documented by Google and Anthropic, this article focuses on it; everything described here is also what any SDK does under the hood.

Credentials first: Application Default Credentials

Application Default Credentials (ADC) is Google Cloud's standard mechanism for letting code discover credentials from its environment instead of from configuration files you manage by hand. For Java, the flow is the same as for every other language:

Local development: run gcloud auth application-default login once. Google's auth libraries for Java then find your user credentials automatically, and short-lived access tokens are minted as needed.

Production: attach a service account to the workload. The account needs the aiplatform.endpoints.predict permission, included in the Vertex AI User role (roles/aiplatform.user). Whoever enabled the Claude models in Model Garden also needed the Consumer Procurement Entitlement Manager role (roles/consumerprocurement.entitlementManager) — but that's a one-time setup task, not something your runtime identity requires. Details in the IAM roles reference.

Each request then carries a bearer token in the Authorization header — the same token you can produce manually with gcloud auth print-access-token when testing with curl.

The request itself

A synchronous (non-streaming) call is an HTTPS POST to Vertex AI's rawPredict method:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID
     /locations/LOCATION/publishers/anthropic/models/MODEL:rawPredict

Three things differ from calling Anthropic directly, and they matter to anyone hand-building requests in Java:

DetailOn Vertex AI
Model nameGoes in the URL path, not the JSON body
API versionBody field anthropic_version, value "vertex-2023-10-16" — not a header
StreamingSame URL with :streamRawPredict; responses arrive as server-sent events

The JSON body is otherwise the familiar Anthropic Messages format: max_tokens, a messages array alternating user and assistant roles (first message must be user), optional system, tools, and so on. Model IDs are bare — claude-opus-4-8, claude-sonnet-5 — with no anthropic. prefix; some older models carry a date suffix such as claude-haiku-4-5@20251001. For LOCATION, use global (with host aiplatform.googleapis.com) for maximum availability, or a specific region; regional and multi-region endpoints cost 10% more than global for Sonnet 4.5 and later models.

Responses come back as a standard Messages API JSON object — a content array of typed blocks, usage counts, and an id with a Vertex-specific msg_vrtx_ prefix. Deserialize with whatever JSON library your stack already uses; there is nothing exotic in the shape.

Rule of thumb: validate your project setup with curl and gcloud auth print-access-token before writing any Java. If curl gets a msg_vrtx_ response, your IAM, billing, and Model Garden enablement are all correct, and any remaining problem is in your code — not your cloud configuration.

Limits and gaps to design around

Request payloads are limited to 30 MB, images to 5 MB each and 100 per request. The Anthropic Message Batches API, Files API, and server-side tools (code execution, web fetch) are not available on Vertex AI — for high-volume async work, Google provides its own batch prediction mechanism instead (see the batch patterns article). Client-side tool use works normally, which suits Java services that already own the business logic Claude needs to call.

Where to go next

Compare with the Python SDK walkthrough and the Node.js path, then keep the common errors reference handy for your first deployment.

Sources