class

Anthropic::Vertex::Client

Inherits Anthropic::Client < Reference < Object

Anthropic models on Google Cloud Vertex AI.

Rewrites canonical /v1/messages calls to Vertex's publisher-model API (.../publishers/anthropic/models/{model}:rawPredict and the streamRawPredict variant) and authenticates with Google OAuth.

client = Anthropic::Vertex::Client.new(
  region: "us-central1",
  project_id: "my-gcp-project",
)

message = client.messages.create(
  model: "claude-sonnet-4-6",
  max_tokens: 256,
  messages: [{role: "user", content: "Hello from Vertex!"}],
)
puts message.text

Credentials resolve via Anthropic::GoogleAuth::Provider: pass access_token: or token_provider:, set GOOGLE_APPLICATION_CREDENTIALS to authorized_user credentials, or run on GCP (metadata server). Service-account key files are not supported (see GoogleAuth).

Not supported on Vertex (matches the official SDKs): the Batch API, Files, and Skills.

Constants

DEFAULT_VERSION = "vertex-2023-10-16"

Constructors

new(region : String | Nil = nil, project_id : String | Nil = nil, base_url : String | Nil = nil, access_token : String | Nil = nil, token_provider : -> String | Nil = nil, credentials_path : String | Path | Nil = nil, timeout : Time::Span = 600.seconds, max_retries : Int32 = DEFAULT_MAX_RETRIES, initial_retry_delay : Float64 = DEFAULT_INITIAL_DELAY, max_retry_delay : Float64 = DEFAULT_MAX_DELAY, default_headers : Hash(String, String) = {} of String => String, middleware : Array = [] of Middleware)
Source

Class methods

default_base_url(region : String) : String
Source

Instance methods

get_stream(path : String, extra_headers : Hash(String, String) | Nil = nil, &)
Source
post_stream(path : String, body, extra_headers : Hash(String, String) | Nil = nil, &)
Source
project_id
Source
region
Source