Skip to content

Commit 8e32b5f

Browse files
feat(vertex): add support for US multi-region endpoint
* feat: vertex us region * fix: remove v1 from base url
1 parent 367ec67 commit 8e32b5f

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎anthropic-java-vertex/src/main/kotlin/com/anthropic/vertex/backends/VertexBackend.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ private constructor(
4545
}
4646

4747
override fun baseUrl(): String =
48-
if (region == "global") "https://aiplatform.googleapis.com"
49-
else "https://$region-aiplatform.googleapis.com"
48+
when (region) {
49+
"global" -> "https://aiplatform.googleapis.com"
50+
"us" -> "https://aiplatform.us.rep.googleapis.com"
51+
else -> "https://$region-aiplatform.googleapis.com"
52+
}
5053

5154
override fun prepareRequest(request: HttpRequest): HttpRequest {
5255
val pathSegments = request.pathSegments

‎anthropic-java-vertex/src/test/kotlin/com/anthropic/vertex/backends/VertexBackendTest.kt‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ internal class VertexBackendTest {
7171
assertThat(backend.baseUrl()).isEqualTo("https://$GC_REGION-aiplatform.googleapis.com")
7272
}
7373

74+
@Test
75+
fun baseUrlGlobalRegion() {
76+
val backend1 = createBackend()
77+
val globalBackend = createBackend(backend1.googleCredentials, "global", backend1.project)
78+
79+
assertThat(globalBackend.baseUrl()).isEqualTo("https://aiplatform.googleapis.com")
80+
}
81+
82+
@Test
83+
fun baseUrlUsRegion() {
84+
val backend1 = createBackend()
85+
val usBackend = createBackend(backend1.googleCredentials, "us", backend1.project)
86+
87+
assertThat(usBackend.baseUrl()).isEqualTo("https://aiplatform.us.rep.googleapis.com")
88+
}
89+
7490
@Test
7591
fun baseUrlOtherRegion() {
7692
// Try with a *different* region to confirm that it is not hard-coded.
@@ -82,14 +98,6 @@ internal class VertexBackendTest {
8298
assertThat(backend2.baseUrl()).isEqualTo("https://$otherRegion-aiplatform.googleapis.com")
8399
}
84100

85-
@Test
86-
fun baseUrlGlobalRegion() {
87-
val backend1 = createBackend()
88-
val globalBackend = createBackend(backend1.googleCredentials, "global", backend1.project)
89-
90-
assertThat(globalBackend.baseUrl()).isEqualTo("https://aiplatform.googleapis.com")
91-
}
92-
93101
@Test
94102
fun prepareRequestMissingJSON() {
95103
val backend = createBackend()

0 commit comments

Comments
 (0)