Class VertexMessagesExample

  • All Implemented Interfaces:

    
    public final class VertexMessagesExample
    
                        

    An example of retrieving messages from an Anthropic model running on the Google Cloud Vertex AI backend.

    To use the VertexBackend, the SDK module for Vertex must be added to the dependencies. Many of the other examples can be adapted to create a client with the VertexBackend (subject to the endpoint being supported). Once a client is created, the rest of the code is the same. See the SDK documentation for details on dependencies and endpoint support for Vertex AI.

    Google OAuth2 credentials must be configured to access Vertex AI. In this example, the OAuth2 _access token_ is retrieved from an environment variable along with the project ID. The region is hard-coded. Alternatively, the Google credentials, region and project can be resolved automatically. See VertexBetaMessagesStreamingAsyncExample for comparison.

    The following environment variables are expected to be defined:

    • GOOGLE_APPLICATION_CREDENTIALS: The value of the access token for Google Cloud Vertex AI.
    • ANTHROPIC_VERTEX_PROJECT_ID: The ID of the Google Cloud Vertex AI project.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void main(Array<String> args)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait