IBM watsonx.ai
Since Camel 4.18
Only producer is supported
The IBM watsonx.ai component allows you to interact with IBM watsonx.ai foundation models for text generation, chat, embeddings, reranking, content detection (PII/HAP), document processing, and other AI capabilities using the IBM watsonx.ai API.
This component is built on top of the IBM watsonx.ai Java SDK.
Prerequisites
You must have a valid IBM Cloud account with access to watsonx.ai services. More information is available at IBM watsonx.ai.
To use this component, you need:
-
An IBM Cloud account
-
Access to watsonx.ai services
-
An API key from IBM Cloud IAM
-
A project ID or deployment space ID
-
(optional) IBM Content Object Storage connection to watsonx
URI Format
ibm-watsonx-ai:label[?options]
You can append query options to the URI in the following format:
?option=value&option2=value&…
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 IBM watsonx.ai component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The watsonx.ai API URL of the region, such as https://us-south.ml.cloud.ibm.com or https://eu-de.ml.cloud.ibm.com. The endpoint does not start without it, unless its operation is runTool or listTools, which call the wxUrl instead, or processToolCalls, which runs locally. | String | ||
The ID of the watsonx.ai project in which the operations of foundation models (textGeneration, chat, embedding, rerank, tokenize, forecast and their streaming variants), detection, text extraction and text classification run. Set projectId or spaceId. deploymentInfo looks the deployment up in this project when no space ID is set. | String | ||
The ID of the deployment space, in the place of projectId, in which the same operations run. deploymentInfo looks the deployment up in this space; there the CamelIBMWatsonxAiSpaceId header overrides it. | String | ||
The watsonx.ai platform (WX) API URL of the region, such as https://api.dataplatform.cloud.ibm.com/wx or https://api.eu-de.dataplatform.cloud.ibm.com/wx, which runTool and listTools call. Required for these two operations. | String | ||
Whether text extraction and classification correct the rotation of the pages. | Boolean | ||
How text classification classifies: exact (the document type) or binary (whether it is one). Enum values:
| String | ||
The configuration that the endpoints share. Each endpoint starts from a copy of it, and its URI options override the copied values. | WatsonxAiConfiguration | ||
The endpoint URL of the IBM Cloud Object Storage region of the document and result buckets, such as https://s3.us-south.cloud-object-storage.appdomain.cloud. Required for text extraction and text classification. | String | ||
The ID of the deployment of deploymentInfo, deploymentGenerate, deploymentChat and deploymentForecast. The CamelIBMWatsonxAiDeploymentId header overrides it; when neither is set, these operations fail. | String | ||
Whether detect looks for hate, abuse and profanity (HAP), when neither the detectors option nor the CamelIBMWatsonxAiDetectors header is set. When neither detectPii nor detectHap is set, detect uses both detectors. | Boolean | ||
The threshold (0 to 1) of the detectors of detect, detectContext and detectGenerated, but the PII detector, which takes none. The defaults of watsonx.ai apply when not set. | Double | ||
The detectors, comma separated, in the place of detectPii and detectHap: hap, pii and granite_guardian for detect, context_relevance and faithfulness for detectContext (default context_relevance), answer_relevance for detectGenerated (default answer_relevance). The detectionThreshold applies to all but pii. | String | ||
Whether detect looks for personal identifiable information (PII), when neither the detectors option nor the CamelIBMWatsonxAiDetectors header is set. When neither detectPii nor detectHap is set, detect uses both detectors. | Boolean | ||
The Cloud Object Storage bucket of the documents of text extraction and text classification: the upload operations upload into it, and the operations with a file path read the document from it. Required for these operations. | String | ||
The ID of the connection asset, in the project or space, that gives watsonx.ai access to the documentBucket. Required for text extraction and text classification. | String | ||
The languages of the documents of text extraction and classification, comma separated ISO 639 codes, such as en,fr. | String | ||
What text extraction does with the images of the document. Enum values:
| String | ||
The quality of text extraction: standard or high_quality. Enum values:
| String | ||
The outputs of text extraction, comma separated: md (the default), json, html, plain_text, page_images. The operations that return the text (AndFetch) take one output, but page_images. | String | ||
The penalty of chat for tokens in proportion to how often they already appear, from -2 to 2: positive values make the answer repeat itself less. There is no header for it. | Double | ||
The watsonx.governance instance that runs the detectors of detectContext and detectGenerated (and of detect, in the place of the project or space), which IBM Cloud requires for them. | String | ||
Guided decoding of chat: the answer is one of these comma separated choices. | String | ||
Guided decoding of chat: the answer follows this context free grammar (EBNF). | String | ||
Guided decoding of chat: the answer matches this regular expression. | String | ||
Whether watsonx.ai returns the reasoning of the model, in the CamelIBMWatsonxAiReasoningContent header. | Boolean | ||
A JSON schema (as JSON text) that the chat answer follows (the json_schema response format). | String | ||
Whether the chat answer must follow the jsonSchema strictly. | true | Boolean | |
The key-value pair extraction of text extraction: disabled, invoice, ubill or generic_with_semantic. When not set, text extraction extracts no key-value pairs. Enum values:
| String | ||
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 of the answer of chat, chatStreaming and deploymentChat. The CamelIBMWatsonxAiMaxNewTokens header overrides it. | Integer | ||
The maximum number of tokens that textGeneration, textGenerationStreaming and deploymentGenerate generate. Chat uses maxCompletionTokens instead. The CamelIBMWatsonxAiMaxNewTokens header overrides it. | Integer | ||
The ID of the foundation model, such as ibm/granite-4-h-small, of textGeneration, chat, embedding, rerank, tokenize, forecast and their streaming variants. The CamelIBMWatsonxAiModelId header overrides it for chat and chatStreaming. The deployment operations use the model of the deployment instead. | String | ||
Chat guardrail: whether watsonx.ai checks the input with Granite Guardian (watsonx.ai applies it to the input only). | Boolean | ||
Chat guardrail: whether watsonx.ai checks the input and the answer for hate, abuse and profanity (HAP). | Boolean | ||
Chat guardrail: whether watsonx.ai checks the input and the answer for personal identifiable information (PII). | Boolean | ||
The threshold (0 to 1) of the HAP and Granite Guardian chat guardrails. | 0.5 | Float | |
How many answers chat generates for the request (n). The body is the first one, and the CamelIBMWatsonxAiAssistantMessages header has them all. | Integer | ||
The optical character recognition of text extraction and classification: auto, disabled, enabled or forced. Enum values:
| String | ||
The operation to perform. The CamelIBMWatsonxAiOperation header overrides it; when neither is set, the exchange fails. Enum values:
| WatsonxAiOperations | ||
The resolution, in dots per inch, of the images that text extraction outputs. | Integer | ||
Whether text extraction gives the tokens of the text, with their positions. | Boolean | ||
The number of time steps to forecast (forecast and deploymentForecast). The model forecasts its own default length when not set. | Integer | ||
The penalty of chat for any token that already appeared, from -2 to 2: positive values make the model move on to new topics. There is no header for it. | Double | ||
How long the text extraction and classification operations that wait (AndFetch) wait for the result, in milliseconds. Defaults to the timeout of the endpoint. | Long | ||
How much the model of chat reasons: low, medium or high, for the models that support it. Enum values:
| String | ||
Whether the text extraction operations that wait (AndFetch) remove the output file from Cloud Object Storage once read (asynchronously). | Boolean | ||
Whether the operations that upload and wait (UploadAndFetch) remove the uploaded document from Cloud Object Storage once the result is read (asynchronously). | Boolean | ||
The penalty of text generation for repeating tokens it already generated: 1 means no penalty, and higher values repeat less. Chat does not use it (see frequencyPenalty). The CamelIBMWatsonxAiRepetitionPenalty header overrides it. | Double | ||
The number of best ranked inputs that rerank returns. The CamelIBMWatsonxAiRerankTopN header overrides it. | Integer | ||
The format of the chat answer: text, or json for a JSON object. Set jsonSchema for an answer that follows a JSON schema. Enum values:
| String | ||
The Cloud Object Storage bucket where text extraction writes its output files, which textExtractionReadFile and textExtractionDeleteFile read and delete unless the CamelIBMWatsonxAiBucketName header names another bucket. Required for text extraction. | String | ||
The ID of the connection asset, in the project or space, that gives watsonx.ai access to the resultBucket. Required for text extraction. | String | ||
Whether each result of rerank includes its input text, besides its index and score. | Boolean | ||
The random seed of chat sampling, for repeatable answers. | Integer | ||
Comma separated sequences that stop the generation of the chat answer. | String | ||
The endpoint URI, such as seda:chunks, that receives each chunk of textGenerationStreaming and chatStreaming as a message when the CamelIBMWatsonxAiStreamConsumer header is not set. The chunks are sent from the threads of the watsonx.ai SDK, with the exchange ID of the streaming exchange in the CamelCorrelationId header. | String | ||
The sampling temperature of text generation and chat (the streaming and deployment operations included), from 0 to 2: higher values give more random text. The CamelIBMWatsonxAiTemperature header overrides it. | Double | ||
Whether the model of chat reasons before it answers, for the models that support it (chat template thinking). | Boolean | ||
For models that write their reasoning in the answer between tags: the tag of the reasoning, and optionally the tag of the answer after a comma, such as think,response. The reasoning goes to the CamelIBMWatsonxAiReasoningContent header and the answer to the body. | String | ||
How the model chooses the tools of chat: auto (the model decides), required (the model must call a tool), none (the model must not call a tool), or the name of the tool the model must call. | String | ||
The top-k sampling of text generation: the model picks the next token from this number of most likely tokens. Chat does not use it. The CamelIBMWatsonxAiTopK header overrides it. | Integer | ||
The nucleus sampling of text generation and chat: the model picks the next token from the most likely tokens whose probabilities add up to this value (0 to 1). The CamelIBMWatsonxAiTopP header overrides it. | Double | ||
The maximum number of tokens of each input text of embedding: a longer input is truncated from the end, so that the request does not fail. | Integer | ||
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 | |
Whether to log HTTP requests to the watsonx.ai API. | false | Boolean | |
Whether to log HTTP responses from the watsonx.ai API. | false | Boolean | |
The timeout of each HTTP request to watsonx.ai and to IBM Cloud IAM, in milliseconds; the watsonx.ai SDK uses 60 seconds when not set. The streaming operations wait for the end of the stream at most this timeout and 30 seconds more. | Long | ||
The IBM Cloud API key, exchanged at IBM Cloud IAM for an access token that is sent to watsonx.ai. Required unless oauthProfile or authenticator is set, or the operation is processToolCalls, which runs locally; when several are set, authenticator is used first, then oauthProfile. | String | ||
OAuth profile name for obtaining an access token via the OAuth 2.0 Client Credentials grant. When set, the token of the configured identity provider is sent to watsonx.ai as a Bearer token instead of an IBM Cloud API key, and obtained again when it expires. Requires camel-oauth on the classpath. | String | ||
Whether the watsonx.ai SDK verifies the TLS certificates of watsonx.ai, IBM Cloud IAM and Cloud Object Storage. Set it to false only for testing, as the connections then accept any certificate. | true | Boolean | |
A custom authenticator of the watsonx.ai SDK (com.ibm.watsonx.ai.core.auth.Authenticator) that gives the token of every request, such as a CP4DAuthenticator for watsonx.ai software on Cloud Pak for Data. When set, apiKey and oauthProfile are not used. | Authenticator |
Endpoint Options
The IBM watsonx.ai endpoint is configured using URI syntax:
ibm-watsonx-ai:label
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The watsonx.ai API URL of the region, such as https://us-south.ml.cloud.ibm.com or https://eu-de.ml.cloud.ibm.com. The endpoint does not start without it, unless its operation is runTool or listTools, which call the wxUrl instead, or processToolCalls, which runs locally. | String | ||
The ID of the watsonx.ai project in which the operations of foundation models (textGeneration, chat, embedding, rerank, tokenize, forecast and their streaming variants), detection, text extraction and text classification run. Set projectId or spaceId. deploymentInfo looks the deployment up in this project when no space ID is set. | String | ||
The ID of the deployment space, in the place of projectId, in which the same operations run. deploymentInfo looks the deployment up in this space; there the CamelIBMWatsonxAiSpaceId header overrides it. | String | ||
The watsonx.ai platform (WX) API URL of the region, such as https://api.dataplatform.cloud.ibm.com/wx or https://api.eu-de.dataplatform.cloud.ibm.com/wx, which runTool and listTools call. Required for these two operations. | String | ||
Whether text extraction and classification correct the rotation of the pages. | Boolean | ||
How text classification classifies: exact (the document type) or binary (whether it is one). Enum values:
| String | ||
The endpoint URL of the IBM Cloud Object Storage region of the document and result buckets, such as https://s3.us-south.cloud-object-storage.appdomain.cloud. Required for text extraction and text classification. | String | ||
The ID of the deployment of deploymentInfo, deploymentGenerate, deploymentChat and deploymentForecast. The CamelIBMWatsonxAiDeploymentId header overrides it; when neither is set, these operations fail. | String | ||
Whether detect looks for hate, abuse and profanity (HAP), when neither the detectors option nor the CamelIBMWatsonxAiDetectors header is set. When neither detectPii nor detectHap is set, detect uses both detectors. | Boolean | ||
The threshold (0 to 1) of the detectors of detect, detectContext and detectGenerated, but the PII detector, which takes none. The defaults of watsonx.ai apply when not set. | Double | ||
The detectors, comma separated, in the place of detectPii and detectHap: hap, pii and granite_guardian for detect, context_relevance and faithfulness for detectContext (default context_relevance), answer_relevance for detectGenerated (default answer_relevance). The detectionThreshold applies to all but pii. | String | ||
Whether detect looks for personal identifiable information (PII), when neither the detectors option nor the CamelIBMWatsonxAiDetectors header is set. When neither detectPii nor detectHap is set, detect uses both detectors. | Boolean | ||
The Cloud Object Storage bucket of the documents of text extraction and text classification: the upload operations upload into it, and the operations with a file path read the document from it. Required for these operations. | String | ||
The ID of the connection asset, in the project or space, that gives watsonx.ai access to the documentBucket. Required for text extraction and text classification. | String | ||
The languages of the documents of text extraction and classification, comma separated ISO 639 codes, such as en,fr. | String | ||
What text extraction does with the images of the document. Enum values:
| String | ||
The quality of text extraction: standard or high_quality. Enum values:
| String | ||
The outputs of text extraction, comma separated: md (the default), json, html, plain_text, page_images. The operations that return the text (AndFetch) take one output, but page_images. | String | ||
The penalty of chat for tokens in proportion to how often they already appear, from -2 to 2: positive values make the answer repeat itself less. There is no header for it. | Double | ||
The watsonx.governance instance that runs the detectors of detectContext and detectGenerated (and of detect, in the place of the project or space), which IBM Cloud requires for them. | String | ||
Guided decoding of chat: the answer is one of these comma separated choices. | String | ||
Guided decoding of chat: the answer follows this context free grammar (EBNF). | String | ||
Guided decoding of chat: the answer matches this regular expression. | String | ||
Whether watsonx.ai returns the reasoning of the model, in the CamelIBMWatsonxAiReasoningContent header. | Boolean | ||
A JSON schema (as JSON text) that the chat answer follows (the json_schema response format). | String | ||
Whether the chat answer must follow the jsonSchema strictly. | true | Boolean | |
The key-value pair extraction of text extraction: disabled, invoice, ubill or generic_with_semantic. When not set, text extraction extracts no key-value pairs. Enum values:
| String | ||
The maximum number of tokens of the answer of chat, chatStreaming and deploymentChat. The CamelIBMWatsonxAiMaxNewTokens header overrides it. | Integer | ||
The maximum number of tokens that textGeneration, textGenerationStreaming and deploymentGenerate generate. Chat uses maxCompletionTokens instead. The CamelIBMWatsonxAiMaxNewTokens header overrides it. | Integer | ||
The ID of the foundation model, such as ibm/granite-4-h-small, of textGeneration, chat, embedding, rerank, tokenize, forecast and their streaming variants. The CamelIBMWatsonxAiModelId header overrides it for chat and chatStreaming. The deployment operations use the model of the deployment instead. | String | ||
Chat guardrail: whether watsonx.ai checks the input with Granite Guardian (watsonx.ai applies it to the input only). | Boolean | ||
Chat guardrail: whether watsonx.ai checks the input and the answer for hate, abuse and profanity (HAP). | Boolean | ||
Chat guardrail: whether watsonx.ai checks the input and the answer for personal identifiable information (PII). | Boolean | ||
The threshold (0 to 1) of the HAP and Granite Guardian chat guardrails. | 0.5 | Float | |
How many answers chat generates for the request (n). The body is the first one, and the CamelIBMWatsonxAiAssistantMessages header has them all. | Integer | ||
The optical character recognition of text extraction and classification: auto, disabled, enabled or forced. Enum values:
| String | ||
The operation to perform. The CamelIBMWatsonxAiOperation header overrides it; when neither is set, the exchange fails. Enum values:
| WatsonxAiOperations | ||
The resolution, in dots per inch, of the images that text extraction outputs. | Integer | ||
Whether text extraction gives the tokens of the text, with their positions. | Boolean | ||
The number of time steps to forecast (forecast and deploymentForecast). The model forecasts its own default length when not set. | Integer | ||
The penalty of chat for any token that already appeared, from -2 to 2: positive values make the model move on to new topics. There is no header for it. | Double | ||
How long the text extraction and classification operations that wait (AndFetch) wait for the result, in milliseconds. Defaults to the timeout of the endpoint. | Long | ||
How much the model of chat reasons: low, medium or high, for the models that support it. Enum values:
| String | ||
Whether the text extraction operations that wait (AndFetch) remove the output file from Cloud Object Storage once read (asynchronously). | Boolean | ||
Whether the operations that upload and wait (UploadAndFetch) remove the uploaded document from Cloud Object Storage once the result is read (asynchronously). | Boolean | ||
The penalty of text generation for repeating tokens it already generated: 1 means no penalty, and higher values repeat less. Chat does not use it (see frequencyPenalty). The CamelIBMWatsonxAiRepetitionPenalty header overrides it. | Double | ||
The number of best ranked inputs that rerank returns. The CamelIBMWatsonxAiRerankTopN header overrides it. | Integer | ||
The format of the chat answer: text, or json for a JSON object. Set jsonSchema for an answer that follows a JSON schema. Enum values:
| String | ||
The Cloud Object Storage bucket where text extraction writes its output files, which textExtractionReadFile and textExtractionDeleteFile read and delete unless the CamelIBMWatsonxAiBucketName header names another bucket. Required for text extraction. | String | ||
The ID of the connection asset, in the project or space, that gives watsonx.ai access to the resultBucket. Required for text extraction. | String | ||
Whether each result of rerank includes its input text, besides its index and score. | Boolean | ||
The random seed of chat sampling, for repeatable answers. | Integer | ||
Comma separated sequences that stop the generation of the chat answer. | String | ||
The endpoint URI, such as seda:chunks, that receives each chunk of textGenerationStreaming and chatStreaming as a message when the CamelIBMWatsonxAiStreamConsumer header is not set. The chunks are sent from the threads of the watsonx.ai SDK, with the exchange ID of the streaming exchange in the CamelCorrelationId header. | String | ||
The sampling temperature of text generation and chat (the streaming and deployment operations included), from 0 to 2: higher values give more random text. The CamelIBMWatsonxAiTemperature header overrides it. | Double | ||
Whether the model of chat reasons before it answers, for the models that support it (chat template thinking). | Boolean | ||
For models that write their reasoning in the answer between tags: the tag of the reasoning, and optionally the tag of the answer after a comma, such as think,response. The reasoning goes to the CamelIBMWatsonxAiReasoningContent header and the answer to the body. | String | ||
How the model chooses the tools of chat: auto (the model decides), required (the model must call a tool), none (the model must not call a tool), or the name of the tool the model must call. | String | ||
The top-k sampling of text generation: the model picks the next token from this number of most likely tokens. Chat does not use it. The CamelIBMWatsonxAiTopK header overrides it. | Integer | ||
The nucleus sampling of text generation and chat: the model picks the next token from the most likely tokens whose probabilities add up to this value (0 to 1). The CamelIBMWatsonxAiTopP header overrides it. | Double | ||
The maximum number of tokens of each input text of embedding: a longer input is truncated from the end, so that the request does not fail. | Integer | ||
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 | |
Whether to log HTTP requests to the watsonx.ai API. | false | Boolean | |
Whether to log HTTP responses from the watsonx.ai API. | false | Boolean | |
The timeout of each HTTP request to watsonx.ai and to IBM Cloud IAM, in milliseconds; the watsonx.ai SDK uses 60 seconds when not set. The streaming operations wait for the end of the stream at most this timeout and 30 seconds more. | Long | ||
The IBM Cloud API key, exchanged at IBM Cloud IAM for an access token that is sent to watsonx.ai. Required unless oauthProfile or authenticator is set, or the operation is processToolCalls, which runs locally; when several are set, authenticator is used first, then oauthProfile. | String | ||
OAuth profile name for obtaining an access token via the OAuth 2.0 Client Credentials grant. When set, the token of the configured identity provider is sent to watsonx.ai as a Bearer token instead of an IBM Cloud API key, and obtained again when it expires. Requires camel-oauth on the classpath. | String | ||
Whether the watsonx.ai SDK verifies the TLS certificates of watsonx.ai, IBM Cloud IAM and Cloud Object Storage. Set it to false only for testing, as the connections then accept any certificate. | true | Boolean | |
A custom authenticator of the watsonx.ai SDK (com.ibm.watsonx.ai.core.auth.Authenticator) that gives the token of every request, such as a CP4DAuthenticator for watsonx.ai software on Cloud Pak for Data. When set, apiKey and oauthProfile are not used. | Authenticator |
Message Headers
The IBM watsonx.ai component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelIBMWatsonxAiOperation (producer) Constant: | The operation to perform. Overrides the operation option. Enum values:
| WatsonxAiOperations | |
CamelIBMWatsonxAiInput (producer) Constant: | The input text, in the place of the body, of textGeneration, textGenerationStreaming, tokenize, deploymentGenerate, detect, detectContext and detectGenerated (for which it is the generated text). | String | |
CamelIBMWatsonxAiInputs (producer) Constant: | The input texts, in the place of the body, of embedding (the texts to embed) and rerank (the texts to rank), as a List of Strings. | List | |
CamelIBMWatsonxAiGeneratedText (producer) Constant: | The generated text of textGeneration, deploymentGenerate, chat, deploymentChat and the streaming operations, which is also the body. For chat, the content of the first answer. | String | |
CamelIBMWatsonxAiModelId (producer) Constant: | The model of chat and chatStreaming for this request, overriding the modelId option. embedding, rerank, tokenize, forecast and deploymentForecast set it to the model that answered. | String | |
CamelIBMWatsonxAiDeploymentId (producer) Constant: | The ID of the deployment of the deployment operations. Overrides the deploymentId option. | String | |
CamelIBMWatsonxAiSpaceId (producer) Constant: | The ID of the deployment space in which deploymentInfo looks the deployment up. Overrides the spaceId option for deploymentInfo only. | String | |
CamelIBMWatsonxAiDeploymentName (producer) Constant: | The name of the deployment, set by deploymentInfo. | String | |
CamelIBMWatsonxAiDeploymentAssetType (producer) Constant: | The type of the asset that the deployment serves, set by deploymentInfo. | String | |
CamelIBMWatsonxAiDeploymentStatus (producer) Constant: | The state of the deployment, set by deploymentInfo. | String | |
CamelIBMWatsonxAiTemperature (producer) Constant: | The sampling temperature of text generation and chat. Overrides the temperature option. | Double | |
CamelIBMWatsonxAiMaxNewTokens (producer) Constant: | The maximum number of tokens to generate. Overrides the maxNewTokens option for text generation and the maxCompletionTokens option for chat. | Integer | |
CamelIBMWatsonxAiTopP (producer) Constant: | The nucleus sampling of text generation and chat. Overrides the topP option. | Double | |
CamelIBMWatsonxAiTopK (producer) Constant: | The top-k sampling of text generation. Overrides the topK option. | Integer | |
CamelIBMWatsonxAiRepetitionPenalty (producer) Constant: | The repetition penalty of text generation. Overrides the repetitionPenalty option. | Double | |
CamelIBMWatsonxAiMessages (producer) Constant: | The chat messages (ChatMessage objects, or Strings as user messages) to send, in the place of the body. When the model answers chat with tool calls, chat sets it to the messages it sent, which processToolCalls extends with the tool calls and the tool results, so the next chat sends the whole conversation. | List | |
CamelIBMWatsonxAiSystemMessage (producer) Constant: | The system message of chat, chatStreaming and deploymentChat, sent before the user message when the CamelIBMWatsonxAiMessages header is not set. Ignored when the body is a ChatMessage or a List of messages. | String | |
CamelIBMWatsonxAiUserMessage (producer) Constant: | The user message of chat, chatStreaming and deploymentChat, in the place of the body, when the CamelIBMWatsonxAiMessages header is not set. | String | |
CamelIBMWatsonxAiTools (producer) Constant: | The tools that the model of chat, chatStreaming and deploymentChat may call, as a List of com.ibm.watsonx.ai.chat.model.Tool. | List | |
CamelIBMWatsonxAiToolChoice (producer) Constant: | How the model chooses the tools of chat, overriding the toolChoice option: auto, required, none, or the name of the tool the model must call. | String | |
CamelIBMWatsonxAiResponseFormat (producer) Constant: | The format of the chat answer, overriding the responseFormat and jsonSchema options: text or json. | String | |
CamelIBMWatsonxAiJsonSchema (producer) Constant: | The JSON schema the chat answer follows, overriding the jsonSchema and responseFormat options: JSON text or a Map. | Object | |
CamelIBMWatsonxAiGuidedChoice (producer) Constant: | Guided decoding of chat, overriding the guidedChoice option: the choices of the answer, as a List or comma separated. | List | |
CamelIBMWatsonxAiSeed (producer) Constant: | The random seed of chat sampling, overriding the seed option. | Integer | |
CamelIBMWatsonxAiStop (producer) Constant: | The stop sequences of chat, overriding the stop option: a List, or comma separated. | List | |
CamelIBMWatsonxAiReasoningEffort (producer) Constant: | How much the model of chat reasons, overriding the reasoningEffort option: low, medium or high. | String | |
CamelIBMWatsonxAiReasoningContent (producer) Constant: | The reasoning of the model that preceded the chat answer, when it gives one. | String | |
CamelIBMWatsonxAiRefusal (producer) Constant: | The refusal of the model to answer, when it refuses. | String | |
CamelIBMWatsonxAiAssistantMessages (producer) Constant: | All the answers of chat when it generates more than one (numberOfChoices), the body being the first. | List | |
CamelIBMWatsonxAiModerationResults (producer) Constant: | The findings of the chat guardrails (moderationHap, moderationPii, moderationGraniteGuardian), by detector. | Map | |
CamelIBMWatsonxAiEmbeddings (producer) Constant: | The embedding vectors of embedding, one List of Floats per input, which is also the body. | List | |
CamelIBMWatsonxAiRerankQuery (producer) Constant: | The query that rerank ranks the inputs against. Required for rerank. | String | |
CamelIBMWatsonxAiRerankTopN (producer) Constant: | The number of best ranked inputs that rerank returns. Overrides the rerankTopN option. | Integer | |
CamelIBMWatsonxAiTokenCount (producer) Constant: | The number of tokens of the input of tokenize, which is also the body. | Integer | |
CamelIBMWatsonxAiTokens (producer) Constant: | The tokens of the input of tokenize. | List | |
CamelIBMWatsonxAiFile (producer) Constant: | The local file that the upload operations of text extraction and text classification upload, when the body is not a file. | File | |
CamelIBMWatsonxAiFileName (producer) Constant: | The name of the document that the upload operations upload when the body is not a file, else taken from the CamelAwsS3Key, CamelAzureStorageBlobBlobName or CamelFileName header. For textExtractionReadFile, textExtractionDeleteFile and textClassificationDeleteFile, the name of the file to read or delete, in the place of the body. | String | |
CamelIBMWatsonxAiFilePath (producer) Constant: | The path of the document in the documentBucket that textExtraction, textExtractionAndFetch, textClassification and textClassificationAndFetch process, in the place of the body. | String | |
CamelIBMWatsonxAiOutputFileName (producer) Constant: | The name of the output file of text extraction, in the result bucket. | String | |
CamelIBMWatsonxAiExtractionId (producer) Constant: | The ID of the text extraction request: set by textExtraction, textExtractionUpload and textExtractionFetch, and read by textExtractionFetch and textExtractionDeleteRequest in the place of the body. | String | |
CamelIBMWatsonxAiExtractionStatus (producer) Constant: | The status of the text extraction request, such as submitted, running, completed or failed, set by textExtraction, textExtractionUpload and textExtractionFetch. | String | |
CamelIBMWatsonxAiExtractedText (producer) Constant: | The extracted text of textExtractionUploadAndFetch and textExtractionAndFetch, which is also the body. | String | |
CamelIBMWatsonxAiBucketName (producer) Constant: | The Cloud Object Storage bucket of the file that textExtractionReadFile, textExtractionDeleteFile (default the resultBucket) and textClassificationDeleteFile (default the documentBucket) read or delete. | String | |
CamelIBMWatsonxAiUploadSuccess (producer) Constant: | Whether textExtractionUploadFile or textClassificationUploadFile uploaded the file, which is also the body. | Boolean | |
CamelIBMWatsonxAiDeleteSuccess (producer) Constant: | Whether the DeleteFile or DeleteRequest operation of text extraction or text classification deleted the file or the request, which is also the body. | Boolean | |
CamelIBMWatsonxAiClassificationId (producer) Constant: | The ID of the text classification request: set by textClassification, textClassificationUpload and textClassificationFetch, and read by textClassificationFetch and textClassificationDeleteRequest in the place of the body. | String | |
CamelIBMWatsonxAiClassificationStatus (producer) Constant: | The status of the text classification request, such as submitted, running, completed or failed, set by the text classification operations that start, fetch or wait for it. | String | |
CamelIBMWatsonxAiClassificationResult (producer) Constant: | The document type that text classification found, set by textClassificationFetch and the AndFetch operations of text classification. | String | |
CamelIBMWatsonxAiDocumentClassified (producer) Constant: | Whether text classification classified the document, set by textClassificationFetch and the AndFetch operations of text classification. | Boolean | |
CamelIBMWatsonxAiErrorMessage (producer) Constant: | The error message of a failed text extraction or text classification request, set by textExtractionFetch and textClassificationFetch. | String | |
CamelIBMWatsonxAiErrorCode (producer) Constant: | The error code of a failed text extraction or text classification request, set by textExtractionFetch and textClassificationFetch. | String | |
CamelIBMWatsonxAiDetectors (producer) Constant: | The detectors of detect, detectContext and detectGenerated, as a List of com.ibm.watsonx.ai.detection.detector.BaseDetector. Overrides the detectors, detectPii and detectHap options. | List | |
CamelIBMWatsonxAiDetectionContext (producer) Constant: | The context of detectContext: the documents, as a List of texts or URLs, or one String. | List | |
CamelIBMWatsonxAiDetectionPrompt (producer) Constant: | The prompt that the generated text of the body of detectGenerated answers. | String | |
CamelIBMWatsonxAiDetected (producer) Constant: | Whether harmful content was detected: true when a detector found something, not counting a Granite Guardian answer of No. | Boolean | |
CamelIBMWatsonxAiDetectionResults (producer) Constant: | Detection results grouped by type: the detection, score and text (and start and end for detect, evidence for detectContext) of each. | Map | |
CamelIBMWatsonxAiDetectionCount (producer) Constant: | Count of the detections that watsonx.ai returned, including Granite Guardian answers of No. | Integer | |
CamelIBMWatsonxAiStreamConsumer (producer) Constant: | The java.util.function.Consumer of String that receives each chunk of textGenerationStreaming and chatStreaming. Overrides the streamEndpoint option; one of them is required for these operations. | Consumer | |
CamelIBMWatsonxAiInputTokenCount (producer) Constant: | The number of tokens of the input, set by text generation, chat, embedding and rerank. | Integer | |
CamelIBMWatsonxAiOutputTokenCount (producer) Constant: | The number of tokens that text generation or chat generated. | Integer | |
CamelIBMWatsonxAiStopReason (producer) Constant: | Why the model stopped generating, as watsonx.ai reports it, such as max_tokens or eos_token for text generation and stop, length or tool_calls for chat. | String | |
CamelIBMWatsonxAiForecastInputSchema (producer) Constant: | The input schema for time series forecast: an InputSchema, or a Map with the keys timestamp_column, id_columns, freq and target_columns (a List or a comma separated String for the columns). | InputSchema | |
CamelIBMWatsonxAiForecastData (producer) Constant: | The forecast data: a ForecastData, or a Map of column name to the List of its values. | ForecastData | |
CamelIBMWatsonxAiForecastPredictionLength (producer) Constant: | The number of time steps to forecast, overriding the predictionLength option. | Integer | |
CamelIBMWatsonxAiForecastFutureData (producer) Constant: | The known future values of the exogenous columns, for deploymentForecast only: a ForecastData, or a Map of column name to the List of its values. | ForecastData | |
CamelIBMWatsonxAiForecastResults (producer) Constant: | The forecast of forecast and deploymentForecast, which is also the body. | List | |
CamelIBMWatsonxAiForecastInputDataPoints (producer) Constant: | The number of data points that forecast or deploymentForecast received. | Integer | |
CamelIBMWatsonxAiForecastOutputDataPoints (producer) Constant: | The number of data points that forecast or deploymentForecast returned. | Integer | |
CamelIBMWatsonxAiFoundationModels (producer) Constant: | The foundation models that listModels returns, which are also the body. | List | |
CamelIBMWatsonxAiFoundationModelTasks (producer) Constant: | The tasks of the foundation models that listTasks returns, which are also the body. | List | |
CamelIBMWatsonxAiFoundationModelFilter (producer) Constant: | The filter of listModels, in the syntax of the filters parameter of watsonx.ai, such as function_text_chat, modelid_ibm/granite-4-h-small or function_rerank,!function_embedding:and (or a com.ibm.watsonx.ai.foundationmodel.filter.Filter). | String | |
CamelIBMWatsonxAiFoundationModelTechPreview (producer) Constant: | Whether listModels includes the tech preview models. | Boolean | |
CamelIBMWatsonxAiToolName (producer) Constant: | The name of the utility tool that runTool runs with the body as its input, such as GoogleSearch or Wikipedia. Required for runTool unless the CamelIBMWatsonxAiToolRequest header is set. | String | |
CamelIBMWatsonxAiToolRequest (producer) Constant: | The complete request of runTool, in the place of the CamelIBMWatsonxAiToolName and CamelIBMWatsonxAiToolConfig headers and the body. | ToolRequest | |
CamelIBMWatsonxAiToolConfig (producer) Constant: | The configuration of the utility tool, as a Map, when runTool builds the request from the CamelIBMWatsonxAiToolName header. | Map | |
CamelIBMWatsonxAiUtilityTools (producer) Constant: | The utility tools that listTools returns, which are also the body. | List | |
CamelIBMWatsonxAiToolRegistry (producer) Constant: | The tool registry that processToolCalls runs the tool calls of the model with. Required for processToolCalls, which keeps it on the message for the next chat. | ToolRegistry | |
CamelIBMWatsonxAiToolCalls (producer) Constant: | The tool calls of the answer of chat, chatStreaming or deploymentChat. Removed when the answer has none, and by processToolCalls once it ran them. | List | |
CamelIBMWatsonxAiHasToolCalls (producer) Constant: | Whether the answer of chat, chatStreaming or deploymentChat calls tools. processToolCalls sets it to false once it ran them. | Boolean | |
CamelIBMWatsonxAiAssistantMessage (producer) Constant: | The first answer of chat, chatStreaming or deploymentChat, with its tool calls. processToolCalls reads it, which it requires, and removes it. | AssistantMessage |
Message Body
The message body at each side of the IBM watsonx.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 or text for textGeneration, tokenize, detect, detectContext (the input), detectGenerated (the generated text) and deploymentGenerate, the file path, ID or file name for the text extraction and classification operations that do not upload, read as text unless a header such as CamelIBMWatsonxAiInput gives it: a Map or a POJO fails, as Camel reads it only as its toString(). chat, chatStreaming and deploymentChat take the user message, read as text the same way, a ChatMessage, or the conversation as a List of ChatMessage in which a String is a user message (any other element fails); embedding and rerank take one text, read as text the same way, or a List of Strings. The upload operations take a file, a stream or bytes, with the CamelIBMWatsonxAiFileName header unless it is a file. runTool takes a Map (structured) or a String; forecast a TimeSeriesRequest unless the CamelIBMWatsonxAiForecastInputSchema and CamelIBMWatsonxAiForecastData headers give it.
|
Producer output |
| The generated text for textGeneration, chat, deploymentGenerate, deploymentChat and the streaming operations, the extracted text for textExtractionUploadAndFetch and textExtractionReadFile, the tool output for runTool, with token counts and the stop reason in headers; textExtractionAndFetch gives the extracted text. embedding gives a List with one List of Floats per input, even for one input; rerank, detect, forecast and the list operations a List of results of the watsonx.ai SDK; tokenize the token count; the uploadFile and delete operations a Boolean. detectContext and detectGenerated give a List of results of the SDK. processToolCalls leaves the body and puts the messages in the CamelIBMWatsonxAiMessages 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.
Required watsonx.ai component options
You must provide the following options to use this component:
-
apiKey- Your IBM Cloud API key for authentication (oroauthProfileorauthenticator, see Authentication) -
baseUrl- The watsonx.ai endpoint URL of your region, such ashttps://us-south.ml.cloud.ibm.com(Dallas) orhttps://eu-de.ml.cloud.ibm.com(Frankfurt) -
projectIdorspaceId- Your IBM Cloud project or deployment space ID -
modelId- The foundation model ID (for model-specific operations) -
(optional)
documentConnectionId,documentBucket,cosUrl- needed by services liketextExtractionortextClassification -
(optional)
wxUrl- For hosted IBM tools
Authentication
The endpoint authenticates in one of three ways. All the services of an endpoint share its authenticator, and so its access token.
-
apiKey: an IBM Cloud API key, which the endpoint exchanges at IBM Cloud IAM for an access token, renewed before it expires. This is the usual way for watsonx.ai on IBM Cloud. -
oauthProfile: the access token of an OAuth 2.0 Client Credentials profile ofcamel-oauth, sent to watsonx.ai as aBearertoken. The identity provider must issue tokens that watsonx.ai accepts, such as an API gateway in front of watsonx.ai or a watsonx.ai software installation that trusts the identity provider: IBM Cloud IAM itself does not offer the Client Credentials grant. -
authenticator: anycom.ibm.watsonx.ai.core.auth.Authenticatorof the watsonx.ai SDK, given as a bean reference, such as aCP4DAuthenticatorfor watsonx.ai software on Cloud Pak for Data.
OAuth profile
Set the oauthProfile parameter to acquire an access token via the OAuth 2.0 Client Credentials grant. This requires camel-oauth on the classpath. The token is asked again for every request: camel-oauth caches it until it expires and then obtains a new one, so a long-running route keeps working. The endpoint fails to start when the profile cannot give a token.
camel.oauth.myidp.client-id=my-client
camel.oauth.myidp.client-secret=my-secret
camel.oauth.myidp.token-endpoint=https://idp.example.com/oauth2/token -
Java
-
XML
-
YAML
from("direct:generate")
.to("ibm-watsonx-ai:myLabel?oauthProfile=myidp&baseUrl={{ibm.watsonx.base-url}}&projectId=my-project&modelId=ibm/granite-4-h-small"); <route>
<from uri="direct:generate"/>
<to uri="ibm-watsonx-ai:myLabel?oauthProfile=myidp&baseUrl={{ibm.watsonx.base-url}}&projectId=my-project&modelId=ibm/granite-4-h-small"/>
</route> - route:
from:
uri: direct:generate
steps:
- to:
uri: ibm-watsonx-ai:myLabel
parameters:
oauthProfile: myidp
baseUrl: "{{ibm.watsonx.base-url}}"
projectId: my-project
modelId: ibm/granite-4-h-small Custom authenticator
The authenticator option takes an authenticator of the watsonx.ai SDK, for example to call watsonx.ai software on Cloud Pak for Data:
import com.ibm.watsonx.ai.core.auth.cp4d.AuthMode;
import com.ibm.watsonx.ai.core.auth.cp4d.CP4DAuthenticator;
@BindToRegistry("cp4d")
public CP4DAuthenticator cp4d() {
return CP4DAuthenticator.builder()
.baseUrl("https://cpd.example.com")
.username("admin")
.apiKey("my-api-key")
.authMode(AuthMode.ZEN_API_KEY)
.build();
}
from("direct:chat")
.to("ibm-watsonx-ai:chat?authenticator=#cp4d&baseUrl=https://cpd.example.com&projectId=my-project"
+ "&modelId=ibm/granite-4-h-small&operation=chat"); Security Considerations
Sensitive Data Logging
When the logRequests option is enabled, HTTP requests to the watsonx.ai API may be logged, which can expose sensitive data including your API key. Only enable request logging in development or debugging scenarios, and ensure logs are properly secured. Never enable request logging in production environments where logs might be accessible to unauthorized parties. |
Usage
Supported Operations
The IBM watsonx.ai component provides the following operations:
Text Generation (Deprecated, use chat instead)
-
textGeneration- Generate text from a prompt -
textGenerationStreaming- Generate text with streaming responses
Chat
-
chat- Chat with conversation history supporting system, user, and assistant messages -
chatStreaming- Chat with streaming responses via callback consumer (theCamelIBMWatsonxAiStreamConsumerheader) or thestreamEndpointoption
The messages come from the CamelIBMWatsonxAiMessages header when it is set. Otherwise the message body gives them: a List is the conversation, in which each element is a ChatMessage or a String (a user message), and any other element fails; a single ChatMessage is a conversation of one message; any other body is the user message, read as text (so a String, a byte[] or an InputStream works), after the system message of the CamelIBMWatsonxAiSystemMessage header if that is set. The CamelIBMWatsonxAiUserMessage header takes the place of the body. deploymentChat reads its messages the same way.
Embeddings
-
embedding- Generate embeddings for text inputs (single or batch)
The texts come from the CamelIBMWatsonxAiInputs header, or from the message body: a List of String, or one text, read as text (so a String, a byte[] or an InputStream works).
Reranking
-
rerank- Rerank documents by relevance to a query
The query comes from the CamelIBMWatsonxAiRerankQuery header, and the documents from the CamelIBMWatsonxAiInputs header or the message body, as for embedding.
Content Detection
-
detect- Detect PII (Personal Identifiable Information) and HAP (Harmful, Abusive, Profane) content in text, or risks with Granite Guardian -
detectContext- Grade how relevant the context (documents, as texts or URLs) is to the input of the body (context_relevance), or how faithful the body is to the context (faithfulness) -
detectGenerated- Grade how relevant the generated text of the body is to its prompt (answer_relevance)
The detectors option names the detectors, such as granite_guardian for detect. In IBM Cloud, the detectors of detectContext and detectGenerated run in a watsonx.governance instance, given by the governanceInstanceId option: with a project or space only, watsonx.ai answers detector_not_accessible.
Document Processing
Text Extraction operations:
-
textExtraction- Start text extraction from documents stored in Cloud Object Storage -
textExtractionFetch- Fetch text extraction results by job ID -
textExtractionUpload- Upload a local file and start extraction -
textExtractionUploadAndFetch- Upload, extract, and return text synchronously -
textExtractionAndFetch- Extract a document already in the document bucket and return its text synchronously -
textExtractionUploadFile- Upload file to COS without starting extraction -
textExtractionReadFile- Read file from COS result bucket -
textExtractionDeleteFile- Delete file from COS -
textExtractionDeleteRequest- Delete extraction job
Text Classification operations:
-
textClassification- Start document classification for documents in Cloud Object Storage -
textClassificationFetch- Fetch classification results by job ID -
textClassificationUpload- Upload a local file and start classification -
textClassificationUploadAndFetch- Upload, classify, and return result synchronously -
textClassificationAndFetch- Classify a document already in the document bucket and return the result synchronously
The options of the text extraction (extractionOutputs, extractionMode, ocrMode, documentLanguages, autoRotationCorrection, embeddedImages, outputDpi, outputTokens, kvpMode) and classification (classificationMode, ocrMode, documentLanguages, autoRotationCorrection) are sent with every request; the CamelIBMWatsonxAiOutputFileName header names the output file. The operations that wait for the result (AndFetch) can remove the uploaded document (removeUploadedFile) and the output file (removeOutputFile) from Cloud Object Storage once the result is read (the SDK removes them asynchronously, so they can still be listed for a moment), and wait at most processingTimeout, which defaults to the timeout of the endpoint. * textClassificationUploadFile - Upload file to COS without starting classification * textClassificationDeleteFile - Delete file from COS * textClassificationDeleteRequest - Delete classification job
| Document processing operations require Cloud Object Storage (COS) configuration with HMAC credentials. See Cloud Object Storage Connection Setup for details. |
Deployment Operations
-
deploymentGenerate- Generate text using deployed models -
deploymentChat- Chat using deployed models -
deploymentForecast- Forecast using deployed time series models
Utility Tools (Experimental)
-
runTool- Run utility tools (GoogleSearch, Weather, WebCrawler, Wikipedia, etc.) -
listTools- List available utility tools -
processToolCalls- Execute tool calls from an assistant message and update the conversation
If you don’t specify an operation explicitly, you must set it via the operation parameter.
Message body read as text
Many operations read the message body as text: the prompt of textGeneration, textGenerationStreaming, tokenize, detect and deploymentGenerate, the user message of the chat operations, the texts of embedding and rerank, and the file path, job id or file name of the extraction and classification operations that do not upload.
Such a body can be a String, a byte[], a stream, a file, anything else Camel converts to its text, such as a char[] or a ByteBuffer, or a value whose text is its toString(): a UUID, a URI, a URL, a java.time value or a Date.
Any other body, such as a Map or a POJO, fails with an IllegalArgumentException, since Camel reads it only as its toString(), which is a dump of its fields rather than a prompt. The rule is the text itself: a body is rejected when the text Camel gives for it is no more than its toString(). Marshal such a body first, for example with marshal().json(), set the body to the text, or, when the toString() of the object is the text to send, say so with convertBodyTo(String.class) before the endpoint.
Common Use Cases
| Use Case | Recommended Operation | Models |
|---|---|---|
Conversational AI, chatbots, Text summarization, Q&A, translation |
| ibm/granite-4-h-small, meta-llama/llama-3-3-70b-instruct |
Semantic search, similarity matching |
| ibm/granite-embedding-278m-multilingual |
RAG document retrieval ranking |
| intfloat/multilingual-e5-large |
Token counting, context management |
| Any text generation model |
Content moderation, compliance |
| N/A (uses built-in detectors) |
Document text extraction |
| N/A (uses document processing pipeline) |
Document classification |
| N/A (uses document processing pipeline) |
Time series forecasting |
| ibm/granite-ttm-512-96-r2, ibm/granite-ttm-1024-96-r2, ibm/granite-ttm-1536-96-r2 (check the availability in your region with |
Model catalog exploration |
| N/A |
Deployed model inference |
| Deployed models |
Web search, weather, web crawling |
| N/A (uses utility tools) |
Chat with tool calling (agentic) |
| ibm/granite-4-h-small, meta-llama/llama-3-3-70b-instruct, mistralai/mistral-small-3-1-24b-instruct-2503 |
Sub-Pages
For more details, see:
-
Examples - Comprehensive examples for chat, embeddings, reranking, content detection, document processing, forecasting, and model operations
Spring Boot and Camel Main Configuration
When using Spring Boot or Camel Main, you can configure the component in application.properties:
This configuration approach works with both Spring Boot (camel-ibm-watsonx-ai-starter) and Camel Main runtimes. |
# watsonx.ai configuration
camel.component.ibm-watsonx-ai.configuration.api-key=${IBM_WATSONX_API_KEY}
camel.component.ibm-watsonx-ai.configuration.base-url=${IBM_WATSONX_URL}
camel.component.ibm-watsonx-ai.configuration.project-id=${IBM_WATSONX_PROJECT_ID}
camel.component.ibm-watsonx-ai.configuration.model-id=ibm/granite-4-h-small
camel.component.ibm-watsonx-ai.configuration.temperature=0.7
camel.component.ibm-watsonx-ai.configuration.max-new-tokens=200 Then use the component in routes without repeating configuration:
-
Java
-
XML
-
YAML
from("direct:generate")
.setBody(constant("Explain microservices architecture"))
.to("ibm-watsonx-ai:gen?operation=textGeneration")
.log("Generated: ${body}"); <route>
<from uri="direct:generate"/>
<setBody>
<constant>Explain microservices architecture</constant>
</setBody>
<to uri="ibm-watsonx-ai:gen?operation=textGeneration"/>
<log message="Generated: ${body}"/>
</route> - route:
from:
uri: direct:generate
steps:
- setBody:
constant: "Explain microservices architecture"
- to:
uri: ibm-watsonx-ai:gen
parameters:
operation: textGeneration
- log:
message: "Generated: ${body}" watsonx.ai Authentication
IBM watsonx.ai uses IBM Cloud IAM (Identity and Access Management) for authentication. You need to provide your IBM Cloud API key.
You can create API keys in the IBM Cloud console:
-
Click "Create an IBM Cloud API key"
-
Copy the API key and use it in your Camel routes
For more information about authentication, see the IBM Cloud IAM documentation.
Cloud Object Storage Connection Setup
Document processing operations (text extraction and classification) require a properly configured IBM Cloud Object Storage (COS) connection in your watsonx.ai project.
| The COS connection must include HMAC credentials (access_key_id and secret_access_key), not just IAM Service Credentials. Without HMAC credentials, you will encounter errors like "EmptyStaticCreds: static credentials are empty". |
Creating COS Credentials with HMAC
-
Go to your IBM Cloud console
-
Navigate to your Cloud Object Storage instance
-
Go to Service credentials tab
-
Click New credential
-
Important: Expand "Advanced options" and enable Include HMAC Credential
-
Create the credential
-
The credential will include both IAM and HMAC keys:
{ "apikey": "...", "cos_hmac_keys": { "access_key_id": "...", "secret_access_key": "..." }, ... }
Creating the COS Connection in watsonx.ai
-
In your watsonx.ai project, go to Manage → Connections
-
Click New connection
-
Select IBM Cloud Object Storage
-
Enter the HMAC credentials (access_key_id and secret_access_key)
-
Save the connection and note the Connection ID
The Connection ID is what you use for the documentConnectionId and resultConnectionId parameters.
Additional Resources
-
For more information about how to create the IBM Cloud Object Storage connection, see the IBM watsonx.ai COS connection documentation.
-
To find the bucket name and COS endpoint for your region, see the IBM Cloud Object Storage buckets documentation.
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ibm-watsonx-ai</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> where x.x.x is the version number of Camel.
The component brings the JSON binding of the watsonx.ai SDK for Jackson 3 (com.ibm.watsonx:watsonx-ai-jackson3). The SDK accepts exactly one binding, so do not add com.ibm.watsonx:watsonx-ai-jackson2 as well.