Camel Spring Boot

Google Vertex AI

Generate text, images and embeddings with Gemini, Imagen and partner models, such as Claude, on Google Cloud Vertex AI.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-google-vertexai-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 19 options, which are listed below.

Name Description Default Type

camel.component.google-vertexai.anthropic-version

The Anthropic API version, for rawPredict and streamRawPredict with publisher anthropic: it is added as anthropic_version to a request that has none. The CamelGoogleVertexAIAnthropicVersion header overrides it.

vertex-2023-10-16

String

camel.component.google-vertexai.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.google-vertexai.candidate-count

The number of response variations (candidates) the model generates, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. The CamelGoogleVertexAIcandidateCount header overrides it. The body has the text of the first candidate only, while the CamelGoogleVertexAICandidatesTokenCount header counts the tokens of all of them.

1

Integer

camel.component.google-vertexai.client

The Google GenAI Client for the generate operations, used in place of the one the endpoint creates from projectId, location and serviceAccountKey. The endpoint does not close a client set here. The option is a com.google.genai.Client type.

Client

camel.component.google-vertexai.configuration

The component configuration. The option is a org.apache.camel.component.google.vertexai.GoogleVertexAIConfiguration type.

GoogleVertexAIConfiguration

camel.component.google-vertexai.enabled

Whether to enable auto configuration of the google-vertexai component. This is enabled by default.

Boolean

camel.component.google-vertexai.health-check-consumer-enabled

Used for enabling or disabling all consumer based health checks from this component

true

Boolean

camel.component.google-vertexai.health-check-producer-enabled

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

Boolean

camel.component.google-vertexai.json-mode

Whether to ask the model for a JSON response: the response MIME type of the GenerateContentConfig is set to application/json, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. The prompt should ask for JSON as well, otherwise the behavior of the model is undefined. Not used by generateImage, generateEmbeddings, rawPredict and streamRawPredict.

false

Boolean

camel.component.google-vertexai.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.google-vertexai.max-output-tokens

The maximum number of tokens that can be generated in the response. It is set in the GenerateContentConfig of generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal, where the CamelGoogleVertexAIMaxOutputTokens header overrides it, and in the request that rawPredict and streamRawPredict build from a plain text prompt.

1024

Integer

camel.component.google-vertexai.operation

The operation to perform, generateText when not set. The CamelGoogleVertexAIOperation header overrides it. generateChat and generateCode send the same request as generateText. rawPredict and streamRawPredict call a partner model, such as Claude, or a custom model through the Prediction Service; the other operations use the Google GenAI client.

GoogleVertexAIOperations

camel.component.google-vertexai.prediction-service-client

The PredictionServiceClient of the Vertex AI SDK (google-cloud-aiplatform) for rawPredict and streamRawPredict, used in place of the one the endpoint creates from location and serviceAccountKey. The endpoint does not close a client set here. The option is a com.google.cloud.aiplatform.v1.PredictionServiceClient type.

PredictionServiceClient

camel.component.google-vertexai.publisher

The publisher of the partner model, such as anthropic, meta or mistralai, for rawPredict and streamRawPredict, which fail without it. The request goes to the endpoint projects/{projectId}/locations/{location}/publishers/{publisher}/models/{modelId}. A plain text prompt is turned into a request in the format of the API of anthropic, meta or mistralai, and into a request with instances and parameters for any other publisher.

String

camel.component.google-vertexai.service-account-key

The location of the JSON key file of the service account that the Vertex AI clients use as credentials. It is loaded as a resource: the classpath:, file:, http: or https: prefix says where from, and a value without a prefix is looked up on the classpath first and then in the file system. When not set, the Application Default Credentials are used, for example from the GOOGLE_APPLICATION_CREDENTIALS environment variable. Not used for a client set with the client or predictionServiceClient option.

String

camel.component.google-vertexai.stream-output-mode

How generateChatStreaming returns the streamed response: complete gives the text of all the chunks joined, chunks gives a List with the text of each chunk. The CamelGoogleVertexAIStreamOutputMode header overrides it. streamRawPredict always joins the chunks.

complete

String

camel.component.google-vertexai.temperature

The temperature, which controls the degree of randomness in token selection: lower values give less open-ended responses, higher values more diverse or creative ones. The range depends on the model, such as 0.0 to 2.0 for Gemini and 0.0 to 1.0 for Claude. It is set in the GenerateContentConfig of generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal, where the CamelGoogleVertexAITemperature header overrides it, and in the request that rawPredict and streamRawPredict build from a plain text prompt.

Float

camel.component.google-vertexai.top-k

The top-K value: for each token selection step, the K tokens with the highest probabilities are sampled, then filtered by top-P, and the final token is selected with temperature sampling. Lower values give less random responses. It is set in the GenerateContentConfig of generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal, where the CamelGoogleVertexAITopK header overrides it, and in the request that rawPredict and streamRawPredict build from a plain text prompt for publisher anthropic or meta.

40

Integer

camel.component.google-vertexai.top-p

The top-P value of nucleus sampling: tokens are selected from the most to the least probable until the sum of their probabilities equals this value. Lower values give less random responses. It is set in the GenerateContentConfig of generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal, where the CamelGoogleVertexAITopP header overrides it, and in the request that rawPredict and streamRawPredict build from a plain text prompt for publisher anthropic or meta.

Float