Camel Components

AWS Bedrock

Since Camel 4.5

Only producer is supported

The AWS2 Bedrock component supports invoking a supported LLM model from AWS Bedrock service.

Prerequisites

You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Bedrock. More information is available at Amazon Bedrock.

URI Format

aws-bedrock://label[?options]

You can append query options to the URI in the following format:

?options=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, *.yaml files, 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 AWS Bedrock component supports the following options which are listed below.

Name Description Default Type

configuration (producer)

The configuration that the endpoints of the component start from. Each endpoint uses a copy of it, in which its own URI options replace the values.

BedrockConfiguration

guardrailIdentifier (producer)

The ID or ARN of the guardrail to apply. converse and converseStream apply it when the CamelAwsBedrockGuardrailConfig header is not set, and applyGuardrail uses it when the CamelAwsBedrockGuardrailIdentifier header is not set. Not used with pojoRequest.

String

guardrailStreamProcessingMode (producer)

How converseStream applies the guardrail of the guardrailIdentifier option to the streamed response. With sync, Bedrock buffers the chunks and checks them with the guardrail before it sends them. With async, Bedrock sends the chunks at once and checks them in the background, so chunks that the guardrail would block can be sent before it blocks the rest, and masking of sensitive information is not supported. Not used when the CamelAwsBedrockGuardrailConfig header is set.

Enum values:

  • sync

  • async

sync

String

guardrailTrace (producer)

Whether converse and converseStream ask for the trace of the guardrail of the guardrailIdentifier option, which the producer gives in the CamelAwsBedrockGuardrailTrace header. Not used when the CamelAwsBedrockGuardrailConfig header is set, and not used by applyGuardrail.

false

boolean

guardrailVersion (producer)

The version of the guardrail, a number such as 1, or DRAFT for its working draft. converse and converseStream use it together with guardrailIdentifier, and applyGuardrail also with the guardrail of the CamelAwsBedrockGuardrailIdentifier header.

DRAFT

String

includeStreamingMetadata (producer)

Whether the streaming operations and converseStream set headers about the response: the chunk count, the completion reason and the token count for the invoke operations, and the chunk count, stop reason, usage and guardrail trace for converseStream, each when the model sends it.

true

boolean

lazyStartProducer (producer)

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

false

boolean

modelId (producer)

Required The ID of the model to invoke, for example anthropic.claude-3-5-sonnet-20241022-v2:0, or of a cross-region inference profile, such as us.anthropic.claude-3-5-sonnet-20241022-v2:0, or its ARN. invokeTextModel and the streaming operations read the response in the format of the model family that the ID names. applyGuardrail does not use it, and with pojoRequest the model of the request is used instead.

Enum values:

  • amazon.titan-text-express-v1

  • amazon.titan-text-lite-v1

  • amazon.titan-image-generator-v1

  • amazon.titan-embed-text-v1

  • amazon.titan-embed-image-v1

  • amazon.titan-text-premier-v1:0

  • amazon.titan-embed-text-v2:0

  • amazon.titan-image-generator-v2:0

  • amazon.nova-canvas-v1:0

  • amazon.nova-lite-v1:0

  • amazon.nova-micro-v1:0

  • amazon.nova-premier-v1:0

  • amazon.nova-pro-v1:0

  • amazon.nova-reel-v1:0

  • amazon.nova-reel-v1:1

  • amazon.nova-sonic-v1:0

  • amazon.rerank-v1:0

  • ai21.jamba-1-5-large-v1:0

  • ai21.jamba-1-5-mini-v1:0

  • anthropic.claude-3-sonnet-20240229-v1:0

  • anthropic.claude-3-5-sonnet-20240620-v1:0

  • anthropic.claude-3-5-sonnet-20241022-v2:0

  • anthropic.claude-3-haiku-20240307-v1:0

  • anthropic.claude-3-5-haiku-20241022-v1:0

  • anthropic.claude-3-opus-20240229-v1:0

  • anthropic.claude-3-7-sonnet-20250219-v1:0

  • anthropic.claude-opus-4-20250514-v1:0

  • anthropic.claude-sonnet-4-20250514-v1:0

  • cohere.command-r-plus-v1:0

  • cohere.command-r-v1:0

  • cohere.embed-english-v3

  • cohere.embed-multilingual-v3

  • cohere.rerank-v3-5:0

  • meta.llama3-8b-instruct-v1:0

  • meta.llama3-70b-instruct-v1:0

  • meta.llama3-1-8b-instruct-v1:0

  • meta.llama3-1-70b-instruct-v1:0

  • meta.llama3-1-405b-instruct-v1:0

  • meta.llama3-2-1b-instruct-v1:0

  • meta.llama3-2-3b-instruct-v1:0

  • meta.llama3-2-11b-instruct-v1:0

  • meta.llama3-2-90b-instruct-v1:0

  • meta.llama3-3-70b-instruct-v1:0

  • meta.llama4-maverick-17b-instruct-v1:0

  • meta.llama4-scout-17b-instruct-v1:0

  • mistral.mistral-7b-instruct-v0:2

  • mistral.mixtral-8x7b-instruct-v0:1

  • mistral.mistral-large-2402-v1:0

  • mistral.mistral-large-2407-v1:0

  • mistral.mistral-small-2402-v1:0

  • mistral.pixtral-large-2502-v1:0

  • stability.sd3-5-large-v1:0

  • stability.stable-image-control-sketch-v1:0

  • stability.stable-image-control-structure-v1:0

  • stability.stable-image-core-v1:1

String

operation (producer)

Required The operation that the producer performs. The CamelAwsBedrockOperation header replaces this option. The invokeImageModelStreaming and invokeEmbeddingsModelStreaming operations are deprecated, as the image generation and embedding models do not stream: use invokeImageModel, invokeEmbeddingsModel or invokeTextModelStreaming instead.

Enum values:

  • invokeTextModel

  • invokeImageModel

  • invokeEmbeddingsModel

  • invokeTextModelStreaming

  • invokeImageModelStreaming

  • invokeEmbeddingsModelStreaming

  • converse

  • converseStream

  • applyGuardrail

BedrockOperations

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request object of the AWS SDK for the operation, which the producer sends as it is: an InvokeModelRequest for the invoke operations, an InvokeModelWithResponseStreamRequest for the streaming ones, or a ConverseRequest, ConverseStreamRequest or ApplyGuardrailRequest. The options and headers that build the request are then not used, and a body of another type fails the exchange.

false

boolean

profileCredentialsName (producer)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

false

String

region (producer)

The AWS region of Amazon Bedrock, as a region ID such as us-east-1, which is the value of Region.US_EAST_1.id(). If not set, the AWS SDK takes the region from its default region provider chain, for example the AWS_REGION environment variable.

Enum values:

  • us-east-1

  • us-east-2

  • us-west-2

  • us-gov-west-1

  • ap-northeast-1

  • ap-northeast-2

  • ap-south-1

  • ap-southeast-1

  • ap-southeast-2

  • ca-central-1

  • eu-central-1

  • eu-central-2

  • eu-west-1

  • eu-west-2

  • eu-west-3

  • sa-east-1

String

streamOutputMode (producer)

How the streaming operations and converseStream give the response: complete gives the whole text as a String, and chunks gives a List of the text of each chunk. In both modes the producer waits until the model has finished. The CamelAwsBedrockStreamOutputMode header replaces this option.

Enum values:

  • complete

  • chunks

complete

String

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

useDefaultCredentialsProvider (producer)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (producer)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

autowiredEnabled (advanced)

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

bedrockRuntimeAsyncClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient for the streaming operations: invokeTextModelStreaming, its deprecated variants and converseStream. When it is not set, the endpoint builds one from the credentials, region, proxy and endpoint override options, also when bedrockRuntimeClient is set. The Camel endpoint does not close a client that is set or autowired.

BedrockRuntimeAsyncClient

bedrockRuntimeClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient for the operations that do not stream: invokeTextModel, invokeImageModel, invokeEmbeddingsModel, converse and applyGuardrail. When this option is set or autowired, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used for this client. The Camel endpoint does not close a client that is set or autowired.

BedrockRuntimeClient

healthCheckConsumerEnabled (health)

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

true

boolean

healthCheckProducerEnabled (health)

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

proxyHost (proxy)

The host name of the proxy that the HTTP clients of Bedrock Runtime connect through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP clients of Bedrock Runtime connect through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP clients of Bedrock Runtime use to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. It is required, unless bedrockRuntimeClient is set or useDefaultCredentialsProvider, useProfileCredentialsProvider or useSessionCredentials is true.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. It is required, unless bedrockRuntimeClient is set or useDefaultCredentialsProvider, useProfileCredentialsProvider or useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. When it is not set, the accessKey and secretKey options are used without a session token.

String

trustAllCertificates (security)

Whether the HTTP clients of Bedrock Runtime trust every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Endpoint Options

The AWS Bedrock endpoint is configured using URI syntax:

aws-bedrock:label

With the following path and query parameters:

Path Parameters

Name Description Default Type

label (producer)

Required A logical name of the endpoint, which you choose freely. The producer does not use it: the model and the operation are given by options and headers.

String

Query Parameters

Name Description Default Type

guardrailIdentifier (producer)

The ID or ARN of the guardrail to apply. converse and converseStream apply it when the CamelAwsBedrockGuardrailConfig header is not set, and applyGuardrail uses it when the CamelAwsBedrockGuardrailIdentifier header is not set. Not used with pojoRequest.

String

guardrailStreamProcessingMode (producer)

How converseStream applies the guardrail of the guardrailIdentifier option to the streamed response. With sync, Bedrock buffers the chunks and checks them with the guardrail before it sends them. With async, Bedrock sends the chunks at once and checks them in the background, so chunks that the guardrail would block can be sent before it blocks the rest, and masking of sensitive information is not supported. Not used when the CamelAwsBedrockGuardrailConfig header is set.

Enum values:

  • sync

  • async

sync

String

guardrailTrace (producer)

Whether converse and converseStream ask for the trace of the guardrail of the guardrailIdentifier option, which the producer gives in the CamelAwsBedrockGuardrailTrace header. Not used when the CamelAwsBedrockGuardrailConfig header is set, and not used by applyGuardrail.

false

boolean

guardrailVersion (producer)

The version of the guardrail, a number such as 1, or DRAFT for its working draft. converse and converseStream use it together with guardrailIdentifier, and applyGuardrail also with the guardrail of the CamelAwsBedrockGuardrailIdentifier header.

DRAFT

String

includeStreamingMetadata (producer)

Whether the streaming operations and converseStream set headers about the response: the chunk count, the completion reason and the token count for the invoke operations, and the chunk count, stop reason, usage and guardrail trace for converseStream, each when the model sends it.

true

boolean

modelId (producer)

Required The ID of the model to invoke, for example anthropic.claude-3-5-sonnet-20241022-v2:0, or of a cross-region inference profile, such as us.anthropic.claude-3-5-sonnet-20241022-v2:0, or its ARN. invokeTextModel and the streaming operations read the response in the format of the model family that the ID names. applyGuardrail does not use it, and with pojoRequest the model of the request is used instead.

Enum values:

  • amazon.titan-text-express-v1

  • amazon.titan-text-lite-v1

  • amazon.titan-image-generator-v1

  • amazon.titan-embed-text-v1

  • amazon.titan-embed-image-v1

  • amazon.titan-text-premier-v1:0

  • amazon.titan-embed-text-v2:0

  • amazon.titan-image-generator-v2:0

  • amazon.nova-canvas-v1:0

  • amazon.nova-lite-v1:0

  • amazon.nova-micro-v1:0

  • amazon.nova-premier-v1:0

  • amazon.nova-pro-v1:0

  • amazon.nova-reel-v1:0

  • amazon.nova-reel-v1:1

  • amazon.nova-sonic-v1:0

  • amazon.rerank-v1:0

  • ai21.jamba-1-5-large-v1:0

  • ai21.jamba-1-5-mini-v1:0

  • anthropic.claude-3-sonnet-20240229-v1:0

  • anthropic.claude-3-5-sonnet-20240620-v1:0

  • anthropic.claude-3-5-sonnet-20241022-v2:0

  • anthropic.claude-3-haiku-20240307-v1:0

  • anthropic.claude-3-5-haiku-20241022-v1:0

  • anthropic.claude-3-opus-20240229-v1:0

  • anthropic.claude-3-7-sonnet-20250219-v1:0

  • anthropic.claude-opus-4-20250514-v1:0

  • anthropic.claude-sonnet-4-20250514-v1:0

  • cohere.command-r-plus-v1:0

  • cohere.command-r-v1:0

  • cohere.embed-english-v3

  • cohere.embed-multilingual-v3

  • cohere.rerank-v3-5:0

  • meta.llama3-8b-instruct-v1:0

  • meta.llama3-70b-instruct-v1:0

  • meta.llama3-1-8b-instruct-v1:0

  • meta.llama3-1-70b-instruct-v1:0

  • meta.llama3-1-405b-instruct-v1:0

  • meta.llama3-2-1b-instruct-v1:0

  • meta.llama3-2-3b-instruct-v1:0

  • meta.llama3-2-11b-instruct-v1:0

  • meta.llama3-2-90b-instruct-v1:0

  • meta.llama3-3-70b-instruct-v1:0

  • meta.llama4-maverick-17b-instruct-v1:0

  • meta.llama4-scout-17b-instruct-v1:0

  • mistral.mistral-7b-instruct-v0:2

  • mistral.mixtral-8x7b-instruct-v0:1

  • mistral.mistral-large-2402-v1:0

  • mistral.mistral-large-2407-v1:0

  • mistral.mistral-small-2402-v1:0

  • mistral.pixtral-large-2502-v1:0

  • stability.sd3-5-large-v1:0

  • stability.stable-image-control-sketch-v1:0

  • stability.stable-image-control-structure-v1:0

  • stability.stable-image-core-v1:1

String

operation (producer)

Required The operation that the producer performs. The CamelAwsBedrockOperation header replaces this option. The invokeImageModelStreaming and invokeEmbeddingsModelStreaming operations are deprecated, as the image generation and embedding models do not stream: use invokeImageModel, invokeEmbeddingsModel or invokeTextModelStreaming instead.

Enum values:

  • invokeTextModel

  • invokeImageModel

  • invokeEmbeddingsModel

  • invokeTextModelStreaming

  • invokeImageModelStreaming

  • invokeEmbeddingsModelStreaming

  • converse

  • converseStream

  • applyGuardrail

BedrockOperations

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

pojoRequest (producer)

Whether the body is the request object of the AWS SDK for the operation, which the producer sends as it is: an InvokeModelRequest for the invoke operations, an InvokeModelWithResponseStreamRequest for the streaming ones, or a ConverseRequest, ConverseStreamRequest or ApplyGuardrailRequest. The options and headers that build the request are then not used, and a body of another type fails the exchange.

false

boolean

profileCredentialsName (producer)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

false

String

region (producer)

The AWS region of Amazon Bedrock, as a region ID such as us-east-1, which is the value of Region.US_EAST_1.id(). If not set, the AWS SDK takes the region from its default region provider chain, for example the AWS_REGION environment variable.

Enum values:

  • us-east-1

  • us-east-2

  • us-west-2

  • us-gov-west-1

  • ap-northeast-1

  • ap-northeast-2

  • ap-south-1

  • ap-southeast-1

  • ap-southeast-2

  • ca-central-1

  • eu-central-1

  • eu-central-2

  • eu-west-1

  • eu-west-2

  • eu-west-3

  • sa-east-1

String

streamOutputMode (producer)

How the streaming operations and converseStream give the response: complete gives the whole text as a String, and chunks gives a List of the text of each chunk. In both modes the producer waits until the model has finished. The CamelAwsBedrockStreamOutputMode header replaces this option.

Enum values:

  • complete

  • chunks

complete

String

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

useDefaultCredentialsProvider (producer)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (producer)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

lazyStartProducer (producer (advanced))

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

bedrockRuntimeAsyncClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient for the streaming operations: invokeTextModelStreaming, its deprecated variants and converseStream. When it is not set, the endpoint builds one from the credentials, region, proxy and endpoint override options, also when bedrockRuntimeClient is set. The Camel endpoint does not close a client that is set or autowired.

BedrockRuntimeAsyncClient

bedrockRuntimeClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient for the operations that do not stream: invokeTextModel, invokeImageModel, invokeEmbeddingsModel, converse and applyGuardrail. When this option is set or autowired, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used for this client. The Camel endpoint does not close a client that is set or autowired.

BedrockRuntimeClient

proxyHost (proxy)

The host name of the proxy that the HTTP clients of Bedrock Runtime connect through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP clients of Bedrock Runtime connect through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP clients of Bedrock Runtime use to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. It is required, unless bedrockRuntimeClient is set or useDefaultCredentialsProvider, useProfileCredentialsProvider or useSessionCredentials is true.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. It is required, unless bedrockRuntimeClient is set or useDefaultCredentialsProvider, useProfileCredentialsProvider or useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. When it is not set, the accessKey and secretKey options are used without a session token.

String

trustAllCertificates (security)

Whether the HTTP clients of Bedrock Runtime trust every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Message Headers

The AWS Bedrock component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelAwsBedrockOperation (producer)

Constant: OPERATION

The operation that the producer performs. It replaces the operation option.

String

CamelAwsBedrockContentType (producer)

Constant: MODEL_CONTENT_TYPE

The MIME type of the request body of the invoke operations, usually application/json. The invoke operations fail without it, unless pojoRequest is true.

String

CamelAwsBedrockAcceptContentType (producer)

Constant: MODEL_ACCEPT_CONTENT_TYPE

The MIME type of the response that the invoke operations ask the model for, usually application/json. The invoke operations fail without it, unless pojoRequest is true.

String

CamelAwsBedrockStreamOutputMode (producer)

Constant: STREAM_OUTPUT_MODE

The output mode of the streaming operations and converseStream: complete or chunks. It replaces the streamOutputMode option.

String

CamelAwsBedrockCompletionReason (producer)

Constant: STREAMING_COMPLETION_REASON

The reason why the model stopped generating, in the terms of its model family, such as end_turn or FINISH. Set by the streaming invoke operations when includeStreamingMetadata is true and the model sends it.

String

CamelAwsBedrockTokenCount (producer)

Constant: STREAMING_TOKEN_COUNT

The number of tokens that the model generated. Set by the streaming invoke operations when includeStreamingMetadata is true and the model sends a count.

Integer

CamelAwsBedrockChunkCount (producer)

Constant: STREAMING_CHUNK_COUNT

The number of chunks of the response stream. Set by the streaming invoke operations and converseStream when includeStreamingMetadata is true.

Integer

CamelAwsBedrockConverseMessages (producer)

Constant: CONVERSE_MESSAGES

The messages of the conversation for converse and converseStream, as a List of Message of the AWS SDK. When not set, the body as text is sent as one user message.

List

CamelAwsBedrockConverseSystem (producer)

Constant: CONVERSE_SYSTEM

The system prompts for converse and converseStream, as a List of SystemContentBlock of the AWS SDK.

List

CamelAwsBedrockConverseInferenceConfig (producer)

Constant: CONVERSE_INFERENCE_CONFIG

The inference parameters for converse and converseStream, such as maxTokens, temperature and topP.

InferenceConfiguration

CamelAwsBedrockConverseToolConfig (producer)

Constant: CONVERSE_TOOL_CONFIG

The tools that the model can ask to use in converse and converseStream, and how it chooses them.

ToolConfiguration

CamelAwsBedrockConverseAdditionalFields (producer)

Constant: CONVERSE_ADDITIONAL_MODEL_REQUEST_FIELDS

The request fields of the model that the Converse API does not define, for converse and converseStream, as a Document of the AWS SDK.

Document

CamelAwsBedrockConverseStopReason (producer)

Constant: CONVERSE_STOP_REASON

The reason why the model stopped generating, such as end_turn, tool_use or max_tokens. Set by converse, and by converseStream when includeStreamingMetadata is true.

String

CamelAwsBedrockConverseUsage (producer)

Constant: CONVERSE_USAGE

The input, output and total token counts of the request. Set by converse, and by converseStream when includeStreamingMetadata is true.

TokenUsage

CamelAwsBedrockConverseOutputMessage (producer)

Constant: CONVERSE_OUTPUT_MESSAGE

The message that the model returned, with all its content blocks, such as the requests to use a tool, while the body has only its text. Set by converse only.

Message

CamelAwsBedrockGuardrailConfig (producer)

Constant: GUARDRAIL_CONFIG

The guardrail to apply in converse and converseStream, as a GuardrailConfiguration of the AWS SDK; converseStream also takes a GuardrailStreamConfiguration. It replaces the guardrailIdentifier, guardrailVersion and guardrailTrace options.

GuardrailConfiguration

CamelAwsBedrockGuardrailIdentifier (producer)

Constant: GUARDRAIL_IDENTIFIER

The ID or ARN of the guardrail for applyGuardrail. It replaces the guardrailIdentifier option. converse and converseStream do not read it.

String

CamelAwsBedrockGuardrailContent (producer)

Constant: GUARDRAIL_CONTENT

The content that applyGuardrail checks, as a List of GuardrailContentBlock of the AWS SDK. When not set, the body as text is checked.

List

CamelAwsBedrockGuardrailSource (producer)

Constant: GUARDRAIL_SOURCE

Whether applyGuardrail checks the content as the input of a model (INPUT) or as its output (OUTPUT). The default is INPUT.

String

CamelAwsBedrockGuardrailOutput (producer)

Constant: GUARDRAIL_OUTPUT

The output of the guardrail, such as the blocked message or the text with masked content. Set by applyGuardrail when the guardrail returns it.

List

CamelAwsBedrockGuardrailTrace (producer)

Constant: GUARDRAIL_TRACE

The trace of the guardrail evaluation. Set by converse, and by converseStream when includeStreamingMetadata is true, when the trace of the guardrail is enabled.

GuardrailTraceAssessment

CamelAwsBedrockGuardrailAssessments (producer)

Constant: GUARDRAIL_ASSESSMENTS

The assessments of the policies of the guardrail, such as its content and topic policies. Set by applyGuardrail.

List

CamelAwsBedrockGuardrailUsage (producer)

Constant: GUARDRAIL_USAGE

The number of text units that each policy of the guardrail processed. Set by applyGuardrail.

GuardrailUsage

Message Body

The message body at each side of the AWS Bedrock 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

text, bytes, stream, file or map

The request of the model as JSON text for the invoke operations, which also need the CamelAwsBedrockContentType and CamelAwsBedrockAcceptContentType headers. Bytes, a stream or a file are sent as they are, and a Map or a Jackson JsonNode is marshalled to JSON: marshal another POJO to JSON first. No body fails. converse and converseStream take the messages of the CamelAwsBedrockConverseMessages header, or else the body as text as one user message; applyGuardrail takes the CamelAwsBedrockGuardrailContent header, or else the body as text. With pojoRequest=true an InvokeModelRequest of the AWS SDK: another body fails.

  • With operation=converse: text

  • With operation=converseStream: text

  • With operation=applyGuardrail: text

Producer output

text or list

The streaming operations and converseStream give the text, or a List of the chunks with streamOutputMode=chunks: an image or embedding model fails, as it does not stream. invokeTextModel gives the JSON response as text for the Amazon Titan models, and a Jackson JsonNode for the others: the response, or the generated text for Llama, Cohere and Claude 2. invokeImageModel gives a JsonNode array of the images as Base64 text, and invokeEmbeddingsModel the InvokeModelResponse of the AWS SDK. converse gives the answer as text, empty when the model asks for a tool, and applyGuardrail its action as text: NONE or GUARDRAIL_INTERVENED.

  • With operation=invokeTextModel: text or pojo

  • With operation=invokeImageModel: pojo

  • With operation=invokeEmbeddingsModel: pojo (software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse)

  • With operation=converse: text (java.lang.String)

  • With operation=applyGuardrail: text (java.lang.String)

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 Bedrock component options

You have to provide the bedrockRuntimeClient in the Registry or your accessKey and secretKey to access the Amazon Bedrock service.

Usage

Static credentials, Default Credential Provider and Profile Credentials Provider

You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.

The order of evaluation for Default Credentials Provider is the following:

  • Java system properties - aws.accessKeyId and aws.secretKey.

  • Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  • Web Identity Token from AWS STS.

  • The shared credentials and config files.

  • Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.

  • Amazon EC2 Instance profile credentials.

You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.

Only one of static, default and profile credentials could be used at the same time.

For more information about this you can look at AWS credentials documentation

Bedrock Producer operations

Camel-AWS Bedrock component provides the following operation on the producer side:

  • invokeTextModel

  • invokeImageModel

  • invokeEmbeddingsModel

  • invokeTextModelStreaming

  • invokeImageModelStreaming (deprecated)

  • invokeEmbeddingsModelStreaming (deprecated)

  • converse

  • converseStream

  • applyGuardrail

The operation must match the model type. Text-generation models are used with invokeTextModel, image-generation models (for example amazon.titan-image-generator-v1, amazon.nova-canvas-v1:0, the stability.* models) with invokeImageModel, and embedding models (for example amazon.titan-embed-text-v1, cohere.embed-english-v3) with invokeEmbeddingsModel. Invoking invokeTextModel with an image, embedding, rerank or video/speech model fails fast with an IllegalArgumentException that names the model and points to the operation to use instead.

The operation is set with the operation option or the CamelAwsBedrockOperation header: with neither, the producer fails with an IllegalArgumentException.

The invoke operations send the message body as the request of the model, in the format the model expects (usually JSON), with the CamelAwsBedrockContentType and CamelAwsBedrockAcceptContentType headers. A String, a byte[], an InputStream or a file is sent as it is, and a Map or a Jackson JsonNode is marshalled to JSON. Marshal another POJO to JSON first. A message with no body fails with an InvalidPayloadException.

With pojoRequest=true, the body is the request of the AWS SDK, and the model of the request is used to read the response, so the modelId option is not needed.

Streaming Support

The streaming operations (invokeTextModelStreaming, invokeImageModelStreaming, invokeEmbeddingsModelStreaming) enable real-time streaming of model responses, providing lower latency and better user experience for interactive applications.

The streaming operations give the generated text. The image generation and embedding models do not stream their response, so the three streaming operations work the same way, and an image or embedding model fails with an IllegalArgumentException that points to invokeImageModel or invokeEmbeddingsModel.

The invokeImageModelStreaming and invokeEmbeddingsModelStreaming operations are deprecated and will be removed in a later release. Use invokeImageModel or invokeEmbeddingsModel with an image generation or embedding model, and invokeTextModelStreaming to stream the text of a text model.

Streaming Output Modes

Two streaming modes are supported:

Complete Mode (default): Accumulates all chunks and returns the complete response as a single message. This is the simplest mode and behaves similarly to non-streaming operations, but with lower time-to-first-token.

Chunks Mode: Returns the chunks as a List in a single message, once the model has finished. Useful when you need to process chunks individually, for example with a split.

Streaming Configuration Options

  • streamOutputMode: Set to "complete" (default) or "chunks"

  • includeStreamingMetadata: Whether to include metadata headers (default: true)

Streaming Metadata Headers

When includeStreamingMetadata is true, the following headers are set:

  • CamelAwsBedrockCompletionReason: The reason the model stopped generating (e.g., "FINISH", "end_turn", "stop")

  • CamelAwsBedrockTokenCount: The number of tokens generated (if provided by the model)

  • CamelAwsBedrockChunkCount: The number of chunks received

Supported Models for Streaming

All text generation models support streaming: - Amazon Titan (all text models) - Anthropic Claude (all versions) - Meta Llama (all versions) - Mistral AI (all models) - Cohere Command models - Amazon Nova models - AI21 Labs Jamba models

A cross-region inference profile id (for example us.anthropic.claude-3-haiku-20240307-v1:0) or an inference profile ARN can be used as the model id, as with invokeTextModel.

Converse API Support

The Converse API provides a unified, model-agnostic interface for conversational AI interactions with AWS Bedrock models. It offers several advantages over the legacy InvokeModel API:

  • Unified Interface: Single API across all supported models (Claude, Llama, Mistral, etc.)

  • Multi-turn Conversations: Native support for conversation history with user/assistant roles

  • Tool Use & Function Calling: Built-in support for tools and function calling

  • System Prompts: First-class support for system-level instructions

  • Structured Responses: Consistent response format across all models

  • Streaming Support: Real-time streaming with the converseStream operation

Converse Operations

Two operations are provided:

converse: Standard request-response conversation

aws-bedrock://label?operation=converse&modelId=anthropic.claude-3-sonnet-20240229-v1:0

converseStream: Streaming conversation with real-time chunk delivery

aws-bedrock://label?operation=converseStream&modelId=anthropic.claude-3-sonnet-20240229-v1:0

Converse Configuration Options

Converse API uses message headers for configuration:

  • CamelAwsBedrockConverseMessages: List of Message objects representing the conversation. When the header is not set, the message body as text is sent as one user message, so a route in YAML or XML (or a Kamelet) can call converse with a text prompt. Without the header and without a body, the exchange fails.

  • CamelAwsBedrockConverseSystem: List of SystemContentBlock for system-level instructions

  • CamelAwsBedrockConverseInferenceConfig: InferenceConfiguration for temperature, maxTokens, etc.

  • CamelAwsBedrockConverseToolConfig: ToolConfiguration for function calling support

  • CamelAwsBedrockConverseAdditionalFields: Document for model-specific additional fields

For streaming operations, you can also use: - CamelAwsBedrockStreamOutputMode: Set to "complete" (default) or "chunks"

For example, the same prompt for every model, with a guardrail, from a text body:

- route:
    from:
      uri: timer:t?repeatCount=1
      steps:
        - setBody:
            constant: "What is Apache Camel?"
        - to: aws-bedrock:label?operation=converse&modelId=anthropic.claude-3-haiku-20240307-v1:0&region=us-east-1&guardrailIdentifier=abc123&guardrailVersion=1
        - log: "${body}"

Converse Response Headers

When a conversation completes, the following headers are set:

  • CamelAwsBedrockConverseStopReason: Why the model stopped (e.g., "end_turn", "max_tokens")

  • CamelAwsBedrockConverseUsage: TokenUsage object with input/output token counts

  • CamelAwsBedrockConverseOutputMessage: The complete Message object from the model (converse only)

  • CamelAwsBedrockGuardrailTrace: The GuardrailTraceAssessment, when a guardrail with trace enabled is applied

  • CamelAwsBedrockChunkCount: (streaming only) Number of chunks received

Supported Models for Converse API

The Converse API supports all modern foundation models on Bedrock:

  • Anthropic Claude 3 family (Haiku, Sonnet, Opus)

  • Anthropic Claude 3.5 family (Sonnet v2, Haiku)

  • Amazon Nova family (Micro, Lite, Pro)

  • Meta Llama 3.x models

  • Mistral AI models

  • Cohere Command R models

Legacy models (Claude 2.x, Claude Instant) are not supported by the Converse API. Use the invokeTextModel operation for those models.

Guardrails Support

AWS Bedrock Guardrails enable you to implement safeguards for your generative AI applications based on your use cases and responsible AI policies. Guardrails can filter harmful content, block sensitive topics, remove personally identifiable information (PII), and enhance content safety and privacy in generative AI applications.

The Camel AWS Bedrock component provides comprehensive support for guardrails through:

  • Converse API Integration: Apply guardrails to conversational interactions

  • Streaming Support: Use guardrails with real-time streaming responses

  • Standalone Validation: Check content against guardrails without invoking a model

  • Flexible Configuration: Configure guardrails at endpoint level or per-message

Guardrails Configuration Options

Endpoint-level Configuration (applies to all requests):

  • guardrailIdentifier: The ID or ARN of the guardrail to apply

  • guardrailVersion: The version of the guardrail (default: "DRAFT")

  • guardrailTrace: Whether to return trace information (default: false)

  • guardrailStreamProcessingMode: How converseStream applies the guardrail to the streamed response, sync or async (default: sync). See Guardrails with converseStream below.

Message-level Configuration (per-message override via headers):

  • CamelAwsBedrockGuardrailConfig: GuardrailConfiguration object for converse operations (converseStream also takes a GuardrailStreamConfiguration)

  • CamelAwsBedrockGuardrailIdentifier: Guardrail identifier String for the applyGuardrail operation (overrides the endpoint guardrailIdentifier)

  • CamelAwsBedrockGuardrailContent: Content blocks for applyGuardrail operation

  • CamelAwsBedrockGuardrailSource: Source type - "INPUT" or "OUTPUT" for applyGuardrail

Guardrails Operations

converse with Guardrails: Apply guardrails to conversational model invocations

aws-bedrock://label?operation=converse&modelId=anthropic.claude-3-sonnet-20240229-v1:0
    &guardrailIdentifier=abc123xyz&guardrailVersion=DRAFT&guardrailTrace=true

converseStream with Guardrails: Apply guardrails to streaming conversations

aws-bedrock://label?operation=converseStream&modelId=anthropic.claude-3-sonnet-20240229-v1:0
    &guardrailIdentifier=abc123xyz&guardrailVersion=DRAFT

Guardrails with converseStream

Bedrock applies a guardrail to a streamed response in one of two processing modes, which the guardrailStreamProcessingMode option chooses for the guardrail of the guardrailIdentifier option:

  • sync (default): Bedrock buffers the response chunks and checks them with the guardrail before it sends them. This adds some latency, but every chunk the producer receives has been checked.

  • async: Bedrock sends the chunks as soon as the model produces them and checks them in the background. Chunks that the guardrail would block can reach the producer before Bedrock blocks the rest of the stream, and the guardrail cannot mask sensitive information.

The guardrailTrace option does not change the processing mode. When the CamelAwsBedrockGuardrailConfig header is a GuardrailStreamConfiguration, its streamProcessingMode is used; a GuardrailConfiguration has none, so Bedrock uses sync.

aws-bedrock://label?operation=converseStream&modelId=anthropic.claude-3-sonnet-20240229-v1:0
    &guardrailIdentifier=abc123xyz&guardrailTrace=true&guardrailStreamProcessingMode=async

applyGuardrail: Standalone operation to validate content against a guardrail without invoking a model. The content is the CamelAwsBedrockGuardrailContent header, or else the message body as text.

aws-bedrock://label?operation=applyGuardrail&guardrailIdentifier=abc123xyz
    &guardrailVersion=DRAFT

Guardrails Response Headers

When using guardrails, the following headers may be set in the response:

  • CamelAwsBedrockGuardrailTrace: Trace information from guardrail evaluation (when trace is enabled)

  • CamelAwsBedrockGuardrailOutput: Output content blocks from applyGuardrail

  • CamelAwsBedrockGuardrailAssessments: Detailed assessments from applyGuardrail

  • CamelAwsBedrockGuardrailUsage: Token usage for guardrail evaluation

Creating a Guardrail in AWS

Before using guardrails, you need to create and configure one in the AWS Bedrock console:

  1. Navigate to AWS Bedrock Console → Guardrails

  2. Click "Create guardrail"

  3. Configure filters:

    • Content filters: Block harmful content (hate, violence, sexual, etc.)

    • Denied topics: Block specific topics you define

    • Word filters: Block or mask custom words/phrases

    • PII filters: Detect and redact personally identifiable information

  4. Save and note your Guardrail ID (e.g., abc123xyz)

Supported Models for Guardrails

Guardrails work with all models that support the Converse API:

  • Anthropic Claude 3 family (Haiku, Sonnet, Opus)

  • Anthropic Claude 3.5 family (Sonnet v2, Haiku)

  • Amazon Nova family (Micro, Lite, Pro)

  • Meta Llama 3.x models

  • Mistral AI models

  • Cohere Command R models

Sub-Pages

For more details on specific features, see:

  • Supported Models - Complete list of supported AWS Bedrock models with JSON request schemas

  • Examples - Producer examples for text, image, embeddings, streaming, conversation, and guardrails

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-aws-bedrock</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.