Documentation
Amazon Bedrock#
You can use Amazon Bedrock models with kagent by leveraging AWS Bedrock's OpenAI Chat Completions API.
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 you want to use. 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#
-
Create a ModelConfig resource that uses the OpenAI-compatible API interface.
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"EOFSetting Description apiKeySecretThe name of the Kubernetes secret storing your AWS API key. apiKeySecretKeyThe key in the secret that stores your AWS API key. modelThe Bedrock model ID to use, such as amazon.titan-text-express-v1oropenai.gpt-oss-20b-1:0.providerSet to OpenAIto use the OpenAI-compatible API interface.openAI.baseUrlThe Bedrock OpenAI-compatible endpoint URL for your chosen region. The baseUrlformat 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.
Kagent Lab: Discover kagent and kmcp
Free, on‑demand lab: build custom AI agents with kagent and integrate tools via kmcp on Kubernetes.