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 the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
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 | ||
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 | |
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 | |
The component configuration. | GoogleVertexAIConfiguration | ||
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 | |
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 | |
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 | |
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. Enum values:
| GoogleVertexAIOperations | ||
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 | ||
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. Enum values:
| complete | String | |
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. | 0.7 | Float | |
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 | |
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. | 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 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. | Client | ||
Autowired 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. | 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:
Path Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Required The ID of the Google Cloud project to call Vertex AI in. It is the project of the GenAI client of the generate operations, and of the endpoint name of rawPredict and streamRawPredict. | String | ||
Required The Google Cloud location of the Vertex AI endpoint, a region such as us-central1, or global. For rawPredict and streamRawPredict, global is replaced by us-east5, as the Prediction Service client needs a regional endpoint. | String | ||
Required The ID of the model to call, such as gemini-2.5-flash for the generate operations, or the ID of the partner model with its version, as the Vertex AI Model Garden lists it, for rawPredict and streamRawPredict. | String |
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
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 | ||
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 | |
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 | |
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 | |
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 | |
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. Enum values:
| GoogleVertexAIOperations | ||
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 | ||
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. Enum values:
| complete | String | |
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. | 0.7 | Float | |
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 | |
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. | 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 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. | Client | ||
Autowired 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. | PredictionServiceClient |
Message Headers
The Google Vertex AI component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelGoogleVertexAIOperation (producer) Constant: | The operation to perform, in place of the operation option. Enum values:
| GoogleVertexAIOperations | |
CamelGoogleVertexAIModelId (producer) Constant: | Set on the response by generateImage, generateEmbeddings, rawPredict and streamRawPredict: the ID of the model that was called. The producer does not read it: the model is the modelId of the endpoint. | String | |
CamelGoogleVertexAIProjectId (producer) Constant: | Not used: the producer does not read or set this header, the project is the projectId of the endpoint. | String | |
CamelGoogleVertexAILocation (producer) Constant: | Not used: the producer does not read or set this header, the location is the location of the endpoint. | String | |
CamelGoogleVertexAITemperature (producer) Constant: | The temperature, in place of the temperature option, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | Float | |
CamelGoogleVertexAITopP (producer) Constant: | The top-P value, in place of the topP option, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | Float | |
CamelGoogleVertexAITopK (producer) Constant: | The top-K value, in place of the topK option, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | Integer | |
CamelGoogleVertexAIMaxOutputTokens (producer) Constant: | The maximum number of output tokens, in place of the maxOutputTokens option, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | Integer | |
CamelGoogleVertexAIcandidateCount (producer) Constant: | The number of candidates to generate, in place of the candidateCount option, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | Integer | |
CamelGoogleVertexAIStreamOutputMode (producer) Constant: | How generateChatStreaming returns the response, complete or chunks, in place of the streamOutputMode option. | String | |
CamelGoogleVertexAIPrompt (producer) Constant: | The prompt, in place of the body, for generateText, generateChat, generateChatStreaming, generateCode and generateImage, and the text part next to the media for generateMultimodal. | String | |
CamelGoogleVertexAIChatMessages (producer) Constant: | Deprecated The chat messages for chat generation. Deprecation note: Not used: the producer does not read this header, and generateChat sends the prompt only, without a conversation history. | List | |
CamelGoogleVertexAISystemInstruction (producer) Constant: | The system instruction for the model, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | String | |
CamelGoogleVertexAISafetySettings (producer) Constant: | The safety settings for content filtering, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal. | List | |
CamelGoogleVertexAIFinishReason (producer) Constant: | Why the model stopped generating tokens in the first candidate, such as STOP or MAX_TOKENS, for generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal (of the last chunk for generateChatStreaming). | String | |
CamelGoogleVertexAIPromptTokenCount (producer) Constant: | The number of tokens in the prompt. | Integer | |
CamelGoogleVertexAICandidatesTokenCount (producer) Constant: | The number of tokens in all the generated candidates. | Integer | |
CamelGoogleVertexAITotalTokenCount (producer) Constant: | The total number of tokens of the request: of the prompt, of the candidates, and of the tool use prompts and the thoughts of the model. | Integer | |
CamelGoogleVertexAISafetyRatings (producer) Constant: | The safety ratings of the first candidate of the response, or of the prompt when it was blocked. | List | |
CamelGoogleVertexAIContentBlocked (producer) Constant: | Whether the prompt was blocked by the safety filters: the response then has no text, and the body is null. A response that a safety filter stops fails the exchange. | Boolean | |
CamelGoogleVertexAIChunkCount (producer generateChatStreaming streamRawPredict) Constant: | The number of streamed chunks: the chunks with text for generateChatStreaming, all the chunks for streamRawPredict. | Integer | |
CamelGoogleVertexAIImageNumberOfImages (producer generateImage) Constant: | The number of images to generate. | Integer | |
CamelGoogleVertexAIImageAspectRatio (producer generateImage) Constant: | The aspect ratio for generated images (e.g., 1:1, 16:9, 9:16, 3:4, 4:3). | String | |
CamelGoogleVertexAIGeneratedImages (producer generateImage) Constant: | The generated images from an image generation operation. | List | |
CamelGoogleVertexAIEmbeddingTaskType (producer generateEmbeddings) Constant: | The task type for embeddings (e.g., RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT, SEMANTIC_SIMILARITY, CLASSIFICATION, CLUSTERING, QUESTION_ANSWERING, FACT_VERIFICATION). | String | |
CamelGoogleVertexAIEmbeddingOutputDimensionality (producer generateEmbeddings) Constant: | The reduced dimension of the output embeddings: the values beyond it are truncated from the end. Not supported by older embedding models. | Integer | |
CamelGoogleVertexAIMediaData (producer generateMultimodal) Constant: | The media bytes, such as an image, to send inline for generateMultimodal. The CamelGoogleVertexAIMediaMimeType header must give its MIME type. | byte[] | |
CamelGoogleVertexAIMediaMimeType (producer generateMultimodal) Constant: | The MIME type of the media of the CamelGoogleVertexAIMediaData or CamelGoogleVertexAIMediaGcsUri header, or of the body, such as image/png, image/jpeg, video/mp4 or audio/mp3. Without it, a file body gets the MIME type of its file name, and a Cloud Storage URI is sent as application/octet-stream. | String | |
CamelGoogleVertexAIMediaGcsUri (producer generateMultimodal) Constant: | The Cloud Storage URI of the media for generateMultimodal, such as gs://bucket/image.png. | String | |
CamelFileName (producer generateMultimodal) Constant: | The name of the file of a file body, such as the body of a file or FTP consumer: when CamelGoogleVertexAIMediaMimeType is not set, generateMultimodal takes the MIME type of the media from the extension of this name. | String | |
CamelGoogleVertexAIPublisher (producer) Constant: | Set on the response by rawPredict and streamRawPredict: the publisher of the partner model. The producer does not read it: the publisher is the publisher option. | String | |
CamelGoogleVertexAIRawResponse (producer) Constant: | The raw response for publisher anthropic, whose body is the text of Claude: the JSON of rawPredict, or the server-sent events of streamRawPredict. | String | |
CamelGoogleVertexAIAnthropicVersion (producer) Constant: | Anthropic API version for Claude models, for rawPredict and streamRawPredict with publisher anthropic: added to a request that has no anthropic_version, in place of the anthropicVersion option. | String |
Message Body
The message body at each side of the Google Vertex AI component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| The prompt for generateText, the default, and the other generate operations, unless the CamelGoogleVertexAIPrompt header has it: bytes, a stream or a file are read as text, a Map or a POJO is sent as its toString(), and no body fails. generateEmbeddings also takes a List of texts. generateMultimodal uses the body only when the CamelGoogleVertexAIMediaData and CamelGoogleVertexAIMediaGcsUri headers are not set: a text body without the CamelGoogleVertexAIPrompt header is the prompt, and any other body, such as bytes, a stream or a file, is sent as media with the MIME type of the CamelGoogleVertexAIMediaMimeType header, or of the file name for a file; it fails without one, and an empty text or byte array is not sent. rawPredict and streamRawPredict take the JSON request as a Map, or as text, bytes, a stream or a file, which are read as text: text that is not JSON is a plain text prompt, and a POJO, a List or no body fails.
|
Producer output |
| The text the model answers for generateText, the default, and the other generate operations, JSON with jsonMode=true, with the token counts, the finish reason and the safety ratings in headers. When the prompt was blocked, the CamelGoogleVertexAIContentBlocked header is true and there is no text: no body, or an empty one for generateChatStreaming. generateChatStreaming joins the chunks, or gives the List of them with streamOutputMode=chunks. The List of the generated images for generateImage, and one vector of Floats per input text for generateEmbeddings. rawPredict and streamRawPredict give the JSON the model answers, or for publisher anthropic the text of Claude with the JSON in the CamelGoogleVertexAIRawResponse header.
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
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
Google Models
Use these operations with Gemini, Imagen, and other Google models:
| Operation | Description |
|---|---|
| Generate text from a prompt |
| Generate chat responses |
| Generate streaming chat responses (accumulated text returned with chunk count) |
| Generate code from a description |
| Generate images using Imagen models |
| Generate text embeddings using embedding models (single text or batch) |
| Generate content from multimodal inputs (text + images/video/audio) |
Partner Models
Use rawPredict and streamRawPredict for Claude, Llama, and Mistral models:
| Operation | Description |
|---|---|
| Send requests to partner models via the Prediction Service API |
| Send streaming requests to partner models (accumulated response with chunk count) |
Partner models require the publisher parameter: anthropic, meta, or mistralai.
Examples
Text Generation with Gemini
-
Java
-
XML
-
YAML
from("direct:prompt")
.setBody(constant("Explain quantum computing briefly"))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash")
.log("${body}"); <route>
<from uri="direct:prompt"/>
<setBody>
<constant>Explain quantum computing briefly</constant>
</setBody>
<to uri="google-vertexai:my-project:us-central1:gemini-2.0-flash"/>
<log message="${body}"/>
</route> - route:
from:
uri: direct:prompt
steps:
- setBody:
constant: Explain quantum computing briefly
- to:
uri: google-vertexai:my-project:us-central1:gemini-2.0-flash
- log:
message: "${body}" Using a Service Account
-
Java
-
XML
-
YAML
from("direct:prompt")
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash?serviceAccountKey=file:/path/to/key.json")
.log("${body}"); <route>
<from uri="direct:prompt"/>
<to uri="google-vertexai:my-project:us-central1:gemini-2.0-flash?serviceAccountKey=file:/path/to/key.json"/>
<log message="${body}"/>
</route> - route:
from:
uri: direct:prompt
steps:
- to:
uri: google-vertexai:my-project:us-central1:gemini-2.0-flash
parameters:
serviceAccountKey: "file:/path/to/key.json"
- log:
message: "${body}" System Instruction and Safety Settings
The generateText, generateChat, generateChatStreaming, generateCode and generateMultimodal operations send the system instruction of the CamelGoogleVertexAISystemInstruction header, and the safety settings of the CamelGoogleVertexAISafetySettings header, a List of com.google.genai.types.SafetySetting. The response sets the CamelGoogleVertexAISafetyRatings header with the safety ratings of the answer.
from("direct:prompt")
.setHeader("CamelGoogleVertexAISystemInstruction", constant("You answer in one sentence"))
.setHeader("CamelGoogleVertexAISafetySettings", constant(List.of(SafetySetting.builder()
.category(HarmCategory.Known.HARM_CATEGORY_HARASSMENT)
.threshold(HarmBlockThreshold.Known.BLOCK_LOW_AND_ABOVE)
.build())))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash")
.log("${body}"); When the safety filters block the prompt, the response has no text: the body is null, and the CamelGoogleVertexAIContentBlocked header is true, with the safety ratings of the prompt in the CamelGoogleVertexAISafetyRatings header. When they stop the answer, the exchange fails with an IllegalArgumentException that names the finish reason, such as SAFETY.
Calling Claude with rawPredict
-
Java
-
XML
-
YAML
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}"); <route>
<from uri="direct:claude"/>
<setBody>
<constant>What is Apache Camel?</constant>
</setBody>
<to uri="google-vertexai:my-project:us-east5:claude-sonnet-4@20250514?operation=rawPredict&publisher=anthropic"/>
<log message="${body}"/>
</route> - route:
from:
uri: direct:claude
steps:
- setBody:
constant: What is Apache Camel?
- to:
uri: "google-vertexai:my-project:us-east5:claude-sonnet-4@20250514"
parameters:
operation: rawPredict
publisher: anthropic
- log:
message: "${body}" The component automatically wraps simple text prompts in the required Anthropic format.
Streaming Chat with Gemini
-
Java
-
XML
-
YAML
from("direct:streaming")
.setBody(constant("Tell me a story"))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash?operation=generateChatStreaming&maxOutputTokens=512")
.log("Response: ${body}, Chunks: ${header.CamelGoogleVertexAIChunkCount}"); <route>
<from uri="direct:streaming"/>
<setBody>
<constant>Tell me a story</constant>
</setBody>
<to uri="google-vertexai:my-project:us-central1:gemini-2.0-flash?operation=generateChatStreaming&maxOutputTokens=512"/>
<log message="Response: ${body}, Chunks: ${header.CamelGoogleVertexAIChunkCount}"/>
</route> - route:
from:
uri: direct:streaming
steps:
- setBody:
constant: Tell me a story
- to:
uri: google-vertexai:my-project:us-central1:gemini-2.0-flash
parameters:
operation: generateChatStreaming
maxOutputTokens: 512
- log:
message: "Response: ${body}, Chunks: ${header.CamelGoogleVertexAIChunkCount}" Image Generation with Imagen
-
Java
-
XML
-
YAML
from("direct:image")
.setBody(constant("A sunset over mountains"))
.setHeader("CamelGoogleVertexAIImageNumberOfImages", constant(1))
.to("google-vertexai:my-project:us-central1:imagen-3.0-generate-002?operation=generateImage")
.log("Generated ${body.size()} image(s)"); <route>
<from uri="direct:image"/>
<setBody>
<constant>A sunset over mountains</constant>
</setBody>
<setHeader name="CamelGoogleVertexAIImageNumberOfImages">
<constant resultType="java.lang.Integer">1</constant>
</setHeader>
<to uri="google-vertexai:my-project:us-central1:imagen-3.0-generate-002?operation=generateImage"/>
<log message="Generated ${body.size()} image(s)"/>
</route> - route:
from:
uri: direct:image
steps:
- setBody:
constant: A sunset over mountains
- setHeader:
name: CamelGoogleVertexAIImageNumberOfImages
constant: "1"
- to:
uri: google-vertexai:my-project:us-central1:imagen-3.0-generate-002
parameters:
operation: generateImage
- log:
message: "Generated ${body.size()} image(s)" The body will contain a List<Image> with the generated images. Each Image has imageBytes() and mimeType() methods.
Text Embeddings
-
Java
-
XML
-
YAML
from("direct:embed")
.setBody(constant("Apache Camel is an integration framework"))
.to("google-vertexai:my-project:us-central1:text-embedding-005?operation=generateEmbeddings")
.log("Embedding dimensions: ${body[0].size()}"); <route>
<from uri="direct:embed"/>
<setBody>
<constant>Apache Camel is an integration framework</constant>
</setBody>
<to uri="google-vertexai:my-project:us-central1:text-embedding-005?operation=generateEmbeddings"/>
<log message="Embedding dimensions: ${body[0].size()}"/>
</route> - route:
from:
uri: direct:embed
steps:
- setBody:
constant: Apache Camel is an integration framework
- to:
uri: google-vertexai:my-project:us-central1:text-embedding-005
parameters:
operation: generateEmbeddings
- log:
message: "Embedding dimensions: ${body[0].size()}" The body will contain a List<List<Float>> — one embedding vector per input text. For batch embeddings, pass a List<String> as the body.
Multimodal Input (Image + Text)
-
Java
-
XML
-
YAML
from("direct:multimodal")
.setHeader("CamelGoogleVertexAIPrompt", constant("Describe this image"))
.setHeader("CamelGoogleVertexAIMediaGcsUri", constant("gs://my-bucket/photo.jpg"))
.setHeader("CamelGoogleVertexAIMediaMimeType", constant("image/jpeg"))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash?operation=generateMultimodal")
.log("${body}"); <route>
<from uri="direct:multimodal"/>
<setHeader name="CamelGoogleVertexAIPrompt">
<constant>Describe this image</constant>
</setHeader>
<setHeader name="CamelGoogleVertexAIMediaGcsUri">
<constant>gs://my-bucket/photo.jpg</constant>
</setHeader>
<setHeader name="CamelGoogleVertexAIMediaMimeType">
<constant>image/jpeg</constant>
</setHeader>
<to uri="google-vertexai:my-project:us-central1:gemini-2.0-flash?operation=generateMultimodal"/>
<log message="${body}"/>
</route> - route:
from:
uri: direct:multimodal
steps:
- setHeader:
name: CamelGoogleVertexAIPrompt
constant: Describe this image
- setHeader:
name: CamelGoogleVertexAIMediaGcsUri
constant: "gs://my-bucket/photo.jpg"
- setHeader:
name: CamelGoogleVertexAIMediaMimeType
constant: image/jpeg
- to:
uri: google-vertexai:my-project:us-central1:gemini-2.0-flash
parameters:
operation: generateMultimodal
- log:
message: "${body}" You can also pass inline image bytes via the CamelGoogleVertexAIMediaData header instead of a GCS URI. The CamelGoogleVertexAIMediaMimeType header is then required: without it the exchange fails.
When neither the CamelGoogleVertexAIMediaData nor the CamelGoogleVertexAIMediaGcsUri header is set, the message body is used:
-
A
Stringbody is the text prompt when theCamelGoogleVertexAIPromptheader is not set. -
Any other body is the media: bytes, an
InputStream, aFile, aPathor the file of a file consumer, read with the type converter. Its MIME type is theCamelGoogleVertexAIMediaMimeTypeheader or, for a file, the one of its file name extension (such asimage/pngforphoto.png). When there is none, the exchange fails, so set the header for bytes or a stream, such as from theContent-Typeof an HTTP request. -
An empty or blank
String, or an empty byte array, is not media: the request has the prompt only, so a body that an earlier step left does not fail it.
For example, to describe the images dropped in a folder:
-
Java
-
YAML
from("file:images")
.setHeader("CamelGoogleVertexAIPrompt", constant("Describe this image"))
.to("google-vertexai:my-project:us-central1:gemini-2.0-flash?operation=generateMultimodal")
.log("${body}"); - route:
from:
uri: file:images
steps:
- setHeader:
name: CamelGoogleVertexAIPrompt
expression:
constant:
expression: Describe this image
- to:
uri: google-vertexai:my-project:us-central1:gemini-2.0-flash
parameters:
operation: generateMultimodal
- log:
message: "${body}" Streaming Claude with streamRawPredict
-
Java
-
XML
-
YAML
from("direct:stream-claude")
.setBody(constant("What is Apache Camel?"))
.to("google-vertexai:my-project:us-east5:claude-sonnet-4@20250514?operation=streamRawPredict&publisher=anthropic")
.log("${body}"); <route>
<from uri="direct:stream-claude"/>
<setBody>
<constant>What is Apache Camel?</constant>
</setBody>
<to uri="google-vertexai:my-project:us-east5:claude-sonnet-4@20250514?operation=streamRawPredict&publisher=anthropic"/>
<log message="${body}"/>
</route> - route:
from:
uri: direct:stream-claude
steps:
- setBody:
constant: What is Apache Camel?
- to:
uri: "google-vertexai:my-project:us-east5:claude-sonnet-4@20250514"
parameters:
operation: streamRawPredict
publisher: anthropic
- log:
message: "${body}" Claude with Custom Request
For more control, pass a JSON body. The request can be a String, bytes, a stream or a file (such as a JSON file or the body of an HTTP request), which is read as text, or a Map, which is written as JSON. Text that is not a JSON object is a plain text prompt, which the component wraps in the format of the publisher. For publisher anthropic, a request without anthropic_version gets the one of the CamelGoogleVertexAIAnthropicVersion header, or else of the anthropicVersion option.
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, generateChatStreaming, generateCode, generateImage, generateEmbeddings, or generateMultimodal:
-
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 or streamRawPredict and the appropriate publisher:
| Publisher | Models | Regions |
|---|---|---|
|
| us-east5, europe-west1 |
|
| us-central1 |
|
| us-central1, europe-west4 |
See VertexAIModels for all available model identifiers.