Amazon Bedrock#
You can use Amazon Bedrock models with kagent in two ways: the native Bedrock provider (recommended) or the OpenAI-compatible API interface.
Option 1: Native Bedrock provider#
The native Bedrock provider uses AWS IAM credentials and the Bedrock API directly. Use this option when you want the simplest configuration and full Bedrock feature support.
Step 1: Prepare your AWS credentials#
-
Create an IAM user or role with permissions for Bedrock. You need at least
bedrock:InvokeModelfor the models you use. For more information, see the AWS Bedrock model access docs. -
Choose the AWS region and Bedrock model. Refer to the AWS Bedrock supported models documentation.
- Example regions:
us-east-1orus-west-2 - Example model IDs:
us.anthropic.claude-sonnet-4-20250514-v1:0oramazon.titan-text-express-v1
- Example regions:
-
Create a Kubernetes secret with your AWS credentials in the same namespace as your agent, typically
kagent:kubectl create secret generic bedrock-credentials -n kagent \--from-literal=AWS_ACCESS_KEY_ID=<your-access-key> \--from-literal=AWS_SECRET_ACCESS_KEY=<your-secret-key>
Step 2: Create the ModelConfig#
kubectl apply -f - <<EOFapiVersion: kagent.dev/v1alpha2kind: ModelConfigmetadata:name: bedrock-nativenamespace: kagentspec:provider: Bedrockmodel: us.anthropic.claude-sonnet-4-20250514-v1:0apiKeySecret: bedrock-credentialsbedrock:region: us-east-1EOF
| Setting | Description |
|---|---|
provider | Set to Bedrock for the native provider. |
model | The Bedrock model ID. Use the format from the AWS Bedrock model IDs (for example, us.anthropic.claude-sonnet-4-20250514-v1:0). |
apiKeySecret | The name of the Kubernetes secret containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. |
bedrock.region | The AWS region where the Bedrock model is available (for example, us-east-1). |
Option 2: OpenAI-compatible API#
You can also use Bedrock models via the OpenAI Chat Completions API. This option is useful when you need compatibility with the OpenAI API format or when using Bedrock's inference profiles.
Step 1: Prepare your AWS details#
-
Follow the AWS Bedrock API keys guide to create the API key needed for authentication.
-
Choose the AWS region and Bedrock model. Refer to the AWS Bedrock supported models documentation.
- Example regions:
us-west-2orus-east-1 - Example model IDs:
amazon.titan-text-express-v1oropenai.gpt-oss-20b-1:0. Ensure your AWS account has access to the chosen model. Some models, like Anthropic models, may require additional access controls. For more information, see the AWS Bedrock model access docs.
- Example regions:
-
Save your AWS API key as an environment variable.
export AWS_API_KEY=<your-aws-api-key> -
Create a Kubernetes secret that stores your AWS API key in the same namespace as your agent, typically
kagent.kubectl create secret generic kagent-bedrock -n kagent --from-literal AWS_API_KEY=$AWS_API_KEY
Step 2: Create the ModelConfig#
kubectl apply -f - <<EOFapiVersion: kagent.dev/v1alpha2kind: ModelConfigmetadata:name: bedrock-confignamespace: kagentspec:apiKeySecret: kagent-bedrockapiKeySecretKey: AWS_API_KEYmodel: amazon.titan-text-express-v1provider: OpenAIopenAI:baseUrl: "https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1"EOF
| Setting | Description |
|---|---|
apiKeySecret | The name of the Kubernetes secret storing your AWS API key. |
apiKeySecretKey | The key in the secret that stores your AWS API key. |
model | The Bedrock model ID to use, such as amazon.titan-text-express-v1 or openai.gpt-oss-20b-1:0. |
provider | Set to OpenAI to use the OpenAI-compatible API interface. |
openAI.baseUrl | The Bedrock OpenAI-compatible endpoint URL for your chosen region. The baseUrl format is: https://bedrock-runtime.<region>.amazonaws.com/openai/v1. |
Next steps#
Now that you configured your Bedrock model, you can create or update an agent to use this model configuration.