Google Vertex AI
Since Camel 4.17
Only producer is supported
This component integrates with Google Cloud Vertex AI, supporting both Google’s native models (Gemini, Imagen) and partner models (Claude, Llama, Mistral) through the rawPredict API.
Prerequisites
-
A Google Cloud Platform account with Vertex AI API enabled
-
A service account with appropriate permissions, or Application Default Credentials configured
For setup instructions, see Vertex AI Documentation.
URI Format
google-vertexai:projectId:location:modelId[?options]
-
projectId- Your GCP project ID -
location- Region where the model is available (e.g.,us-central1,us-east5) -
modelId- Model identifier (e.g.,gemini-2.0-flash,claude-sonnet-4@20250514)
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Google Vertex AI component supports 18 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The Service account key that can be used as credentials for the Vertex AI client. It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems. | String | ||
Anthropic API version for Claude models. Required when publisher is 'anthropic'. | vertex-2023-10-16 | String | |
Number of candidate responses to generate. | 1 | Integer | |
The component configuration. | GoogleVertexAIConfiguration | ||
Whether to use JSON request/response format. | false | boolean | |
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 | |
Maximum number of output tokens. | 1024 | Integer | |
Set the operation for the producer. Enum values:
| GoogleVertexAIOperations | ||
Publisher name for partner models (e.g., anthropic, meta, mistralai). Required for rawPredict operations. | String | ||
Streaming output mode: complete (default) or chunks. Enum values:
| complete | String | |
Temperature parameter for generation (0.0-1.0). | 0.7 | Float | |
Top-K parameter for generation. | 40 | Integer | |
Top-P parameter for nucleus sampling. | 0.95 | Float | |
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 | |
Autowired The Google GenAI client for Vertex AI. | Client | ||
Autowired The Google Cloud AI Platform Prediction Service client for rawPredict operations. | PredictionServiceClient | ||
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
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 |
Endpoint Options
The Google Vertex AI endpoint is configured using URI syntax:
google-vertexai:projectId:location:modelId
With the following path and query parameters:
Query Parameters (14 parameters)
| Name | Description | Default | Type |
|---|---|---|---|
The Service account key that can be used as credentials for the Vertex AI client. It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems. | String | ||
Anthropic API version for Claude models. Required when publisher is 'anthropic'. | vertex-2023-10-16 | String | |
Number of candidate responses to generate. | 1 | Integer | |
Whether to use JSON request/response format. | false | boolean | |
Maximum number of output tokens. | 1024 | Integer | |
Set the operation for the producer. Enum values:
| GoogleVertexAIOperations | ||
Publisher name for partner models (e.g., anthropic, meta, mistralai). Required for rawPredict operations. | String | ||
Streaming output mode: complete (default) or chunks. Enum values:
| complete | String | |
Temperature parameter for generation (0.0-1.0). | 0.7 | Float | |
Top-K parameter for generation. | 40 | Integer | |
Top-P parameter for nucleus sampling. | 0.95 | Float | |
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 | |
Autowired The Google GenAI client for Vertex AI. | Client | ||
Autowired The Google Cloud AI Platform Prediction Service client for rawPredict operations. | PredictionServiceClient |
Message Headers
The Google Vertex AI component supports 24 message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelGoogleVertexAIOperation (producer) Constant: | The operation to perform. Enum values:
| GoogleVertexAIOperations | |
CamelGoogleVertexAIModelId (producer) Constant: | The model ID to use for generation. | String | |
CamelGoogleVertexAIProjectId (producer) Constant: | The project ID to use for the request. | String | |
CamelGoogleVertexAILocation (producer) Constant: | The location/region to use for the request. | String | |
CamelGoogleVertexAITemperature (producer) Constant: | The temperature parameter for generation (0.0-1.0). | Float | |
CamelGoogleVertexAITopP (producer) Constant: | The top-p parameter for generation. | Float | |
CamelGoogleVertexAITopK (producer) Constant: | The top-k parameter for generation. | Integer | |
CamelGoogleVertexAIMaxOutputTokens (producer) Constant: | The maximum number of output tokens. | Integer | |
CamelGoogleVertexAIcandidateCount (producer) Constant: | The number of candidate responses to generate. | Integer | |
CamelGoogleVertexAIStreamOutputMode (producer) Constant: | The streaming output mode (complete or chunks). | String | |
CamelGoogleVertexAIPrompt (producer) Constant: | The prompt text for text generation. | String | |
CamelGoogleVertexAIChatMessages (producer) Constant: | The chat messages for chat generation. | List | |
CamelGoogleVertexAISystemInstruction (producer) Constant: | The system instruction for the model. | String | |
CamelGoogleVertexAISafetySettings (producer) Constant: | The safety settings for content filtering. | List | |
CamelGoogleVertexAIFinishReason (producer) Constant: | The finish reason from the response. | String | |
CamelGoogleVertexAIPromptTokenCount (producer) Constant: | The number of tokens in the prompt. | Integer | |
CamelGoogleVertexAICandidatesTokenCount (producer) Constant: | The number of tokens in the response. | Integer | |
CamelGoogleVertexAITotalTokenCount (producer) Constant: | The total token count (prompt response). | Integer | |
CamelGoogleVertexAISafetyRatings (producer) Constant: | The safety ratings from the response. | List | |
CamelGoogleVertexAIContentBlocked (producer) Constant: | Whether the content was blocked by safety filters. | Boolean | |
CamelGoogleVertexAIChunkCount (producer) Constant: | The number of chunks received in streaming response. | Integer | |
CamelGoogleVertexAIPublisher (producer) Constant: | Publisher name for partner models (e.g., anthropic, meta, mistralai). | String | |
CamelGoogleVertexAIRawResponse (producer) Constant: | The raw JSON response from rawPredict operation. | String | |
CamelGoogleVertexAIAnthropicVersion (producer) Constant: | Anthropic API version for Claude models. | String |
Authentication
The component supports two authentication methods:
-
Service Account Key File - Set the
serviceAccountKeyparameter to a file path:serviceAccountKey=file:/path/to/service-account.json
-
Application Default Credentials - If no key is provided, the component uses ADC automatically.
Operations
Examples
Text Generation with Gemini
from("direct:prompt")
.setBody(constant("Explain quantum computing briefly"))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash")
.log("${body}"); Using a Service Account
from("direct:prompt")
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash"
+ "?serviceAccountKey=file:/path/to/key.json")
.log("${body}"); Calling Claude with rawPredict
from("direct:claude")
.setBody(constant("What is Apache Camel?"))
.to("google-vertexai:my-project:us-east5:claude-sonnet-4@20250514"
+ "?operation=rawPredict&publisher=anthropic")
.log("${body}"); The component automatically wraps simple text prompts in the required Anthropic format.
Claude with Custom Request
For more control, pass a JSON or Map body:
from("direct:claude")
.process(exchange -> {
String json = """
{
"anthropic_version": "vertex-2023-10-16",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Write a haiku"}]
}
""";
exchange.getMessage().setBody(json);
})
.to("google-vertexai:my-project:us-east5:claude-sonnet-4@20250514"
+ "?operation=rawPredict&publisher=anthropic")
.log("${body}"); Supported Models
Google Models
Use with generateText, generateChat, or generateCode:
-
Gemini:
gemini-2.5-pro,gemini-2.5-flash,gemini-2.0-flash,gemini-1.5-pro,gemini-1.5-flash -
Imagen:
imagen-4.0-generate-preview-05-20,imagen-3.0-generate-002 -
Gemma:
gemma-3-27b-it,gemma-2-27b-it,gemma-2-9b-it -
Embeddings:
text-embedding-005,text-embedding-004
Partner Models
Use with rawPredict and the appropriate publisher:
| Publisher | Models | Regions |
|---|---|---|
|
| us-east5, europe-west1 |
|
| us-central1 |
|
| us-central1, europe-west4 |
See VertexAIModels for all available model identifiers.
Dependencies
Add the following dependency:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-google-vertexai</artifactId>
<version>x.x.x</version>
</dependency> Spring Boot Auto-Configuration
When using google-vertexai with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-google-vertexai-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> The component supports 19 options, which are listed below.