Skip to content

Commit fe43d03

Browse files
authored
fix(vertex): use correct Vertex AI hostname for global region (#12)
The Vertex AI "global" endpoint is aiplatform.googleapis.com with no region prefix.
1 parent f76049d commit fe43d03

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Sources/AgentRunKit/LLM/VertexAnthropicClient.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ public struct VertexAnthropicClient: LLMClient, Sendable {
226226
let action = stream ? "streamRawPredict" : "rawPredict"
227227
let basePath = "v1/projects/\(projectID)/locations/\(location)"
228228
+ "/publishers/anthropic/models/\(modelIdentifier):\(action)"
229-
guard let baseURL = URL(string: "https://\(location)-aiplatform.googleapis.com") else {
229+
let host =
230+
if location == "global" {
231+
"https://aiplatform.googleapis.com"
232+
} else {
233+
"https://\(location)-aiplatform.googleapis.com"
234+
}
235+
guard let baseURL = URL(string: host) else {
230236
throw AgentError.llmError(.other("Invalid Vertex AI location: \(location)"))
231237
}
232238
let url = baseURL.appendingPathComponent(basePath)

Sources/AgentRunKit/LLM/VertexGoogleClient.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ public struct VertexGoogleClient: LLMClient, Sendable {
172172
let action = stream ? "streamGenerateContent" : "generateContent"
173173
let basePath = "\(apiVersion)/projects/\(projectID)/locations/\(location)"
174174
+ "/publishers/google/models/\(modelIdentifier):\(action)"
175-
guard let baseURL = URL(string: "https://\(location)-aiplatform.googleapis.com") else {
175+
let host =
176+
if location == "global" {
177+
"https://aiplatform.googleapis.com"
178+
} else {
179+
"https://\(location)-aiplatform.googleapis.com"
180+
}
181+
guard let baseURL = URL(string: host) else {
176182
throw AgentError.llmError(.other("Invalid Vertex AI location: \(location)"))
177183
}
178184
var url = baseURL.appendingPathComponent(basePath)

0 commit comments

Comments
 (0)