Skip to content

Raw API client ​

When you need full access to the Vertex AI REST API beyond what the ExpressModelClient exposes, the generated client under com.anymindgroup.gcp.aiplatform.v1 can be used directly with an authenticated backend:

scala
import zio.*

import com.anymindgroup.gcp.*
import auth.defaultAccessTokenBackend
import aiplatform.v1.*
import aiplatform.v1.resources.*
import aiplatform.v1.schemas.*

object vertex_ai_generate_content extends ZIOAppDefault:
  def run = for
    authedBackend <- defaultAccessTokenBackend()
    endpoint       = Endpoint.`asia-northeast1`
    request        = projects.locations.publishers.Models.generateContent(
                projectsId = "my-gcp-project",
                locationsId = endpoint.location,
                publishersId = "google",
                modelsId = "gemini-3.5-flash",
                request = GoogleCloudAiplatformV1GenerateContentRequest(
                  contents = Chunk(
                    GoogleCloudAiplatformV1Content(
                      parts = Chunk(
                        GoogleCloudAiplatformV1Part(
                          text = Some("hello how are you doing?")
                        )
                      ),
                      role = Some("user"),
                    )
                  ),
                  generationConfig = Some(
                    GoogleCloudAiplatformV1GenerationConfig(
                      thinkingConfig =
                        Some(GoogleCloudAiplatformV1GenerationConfigThinkingConfig(includeThoughts = Some(true)))
                    )
                  ),
                ),
                endpointUrl = endpoint.url,
              )
    _ <- authedBackend
           .send(request)
           .flatMap:
             _.body match
               case Right(body) => ZIO.logInfo(s"Response ok: $body")
               case Left(err)   => ZIO.logError(s"Failure: $err")
  yield ()