Anthropic::GoogleCloud::Client
Inherits Anthropic::Client < Reference < Object
Claude API on the Google Cloud gateway — the first-party Anthropic API served through Google Cloud.
Unlike Anthropic::Vertex::Client (publisher-model :rawPredict
API, messages only), this client speaks the full first-party API:
requests pass through the gateway unchanged — standard /v1/* paths,
standard model names, the complete API surface.
client = Anthropic::GoogleCloud::Client.new(
project: "my-gcp-project",
location: "global",
workspace_id: "ws_123",
)
message = client.messages.create(
model: Anthropic::Model::CLAUDE_SONNET_5,
max_tokens: 256,
messages: [{role: "user", content: "Hello!"}],
)
Authentication uses Google credentials unless skip_auth is true:
token_provider (a proc returning a token, called per request),
an explicit access_token, or Application Default Credentials via
Anthropic::GoogleAuth::Provider.
Constants
URL_TEMPLATE = "https://claude.googleapis.com/v1alpha/projects/%<project>s/locations/%<location>s/workspaces/%<workspace_id>s/invoke"
Gateway base URL template.
Constructors
new(project : String | Nil = nil, location : String | Nil = nil, workspace_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, skip_auth : Bool = false, 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)
SourceInstance methods
location
Sourcepost_multipart(path : String, file : IO, filename : String, content_type : String = "application/octet-stream", extra_headers : Hash(String, String) | Nil = nil) : HTTP::Client::Response
Sourcepost_multipart_files(path : String, files : Array(FileUpload), form_fields : Hash(String, String) | Nil = nil, extra_headers : Hash(String, String) | Nil = nil) : HTTP::Client::Response
Sourceproject
Sourceworkspace_id
Source