|
| 1 | +--- |
| 2 | +title: "Amazon Bedrock" |
| 3 | +pageOrder: 1 |
| 4 | +description: "Use Amazon Bedrock models with kagent via the OpenAI Chat Completions API." |
| 5 | +--- |
| 6 | + |
| 7 | +export const metadata = { |
| 8 | + title: "Amazon Bedrock", |
| 9 | + description: "Use Amazon Bedrock models with kagent via the OpenAI Chat Completions API.", |
| 10 | + author: "kagent.dev" |
| 11 | +}; |
| 12 | + |
| 13 | +# Amazon Bedrock |
| 14 | + |
| 15 | +You can use Amazon Bedrock models with kagent by leveraging AWS Bedrock's [OpenAI Chat Completions API](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions.html). |
| 16 | + |
| 17 | +## Step 1: Prepare your AWS details |
| 18 | + |
| 19 | +1. Follow the [AWS Bedrock API keys guide](https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started-api-keys.html) to create the API key needed for authentication. |
| 20 | + |
| 21 | +2. Choose the AWS region and Bedrock model you want to use. Refer to the [AWS Bedrock supported models documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html). |
| 22 | + - Example Regions: `us-west-2` or `us-east-1` |
| 23 | + - Example model IDs: `amazon.titan-text-express-v1` or `openai.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](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html). |
| 24 | + |
| 25 | +3. Save your AWS API key as an environment variable. |
| 26 | + |
| 27 | + ```bash |
| 28 | + export AWS_API_KEY=<your-aws-api-key> |
| 29 | + ``` |
| 30 | + |
| 31 | +4. Create a Kubernetes secret that stores your AWS API key in the same namespace as your agent, typically `kagent`. |
| 32 | + |
| 33 | + ```bash |
| 34 | + kubectl create secret generic kagent-bedrock -n kagent --from-literal AWS_API_KEY=$AWS_API_KEY |
| 35 | + ``` |
| 36 | + |
| 37 | +## Step 2: Create the ModelConfig |
| 38 | + |
| 39 | +1. Create a ModelConfig resource that uses the OpenAI-compatible API interface. |
| 40 | + |
| 41 | + ```yaml |
| 42 | + kubectl apply -f - <<EOF |
| 43 | + apiVersion: kagent.dev/v1alpha2 |
| 44 | + kind: ModelConfig |
| 45 | + metadata: |
| 46 | + name: bedrock-config |
| 47 | + namespace: kagent |
| 48 | + spec: |
| 49 | + apiKeySecret: kagent-bedrock |
| 50 | + apiKeySecretKey: AWS_API_KEY |
| 51 | + model: amazon.titan-text-express-v1 |
| 52 | + provider: OpenAI |
| 53 | + openAI: |
| 54 | + baseUrl: "https://bedrock-runtime.us-west-2.amazonaws.com/openai/v1" |
| 55 | + EOF |
| 56 | + ``` |
| 57 | + |
| 58 | + | Setting | Description | |
| 59 | + | --- | --- | |
| 60 | + | `apiKeySecret` | The name of the Kubernetes secret storing your AWS API key. | |
| 61 | + | `apiKeySecretKey` | The key in the secret that stores your AWS API key. | |
| 62 | + | `model` | The Bedrock model ID to use, such as `amazon.titan-text-express-v1` or `openai.gpt-oss-20b-1:0`. | |
| 63 | + | `provider` | Set to `OpenAI` to use the OpenAI-compatible API interface. | |
| 64 | + | `openAI.baseUrl` | The Bedrock OpenAI-compatible endpoint URL for your chosen region. The `baseUrl` format is: `https://bedrock-runtime.<region>.amazonaws.com/openai/v1`. | |
| 65 | + |
| 66 | +## Next Steps |
| 67 | + |
| 68 | + Now that you configured your Bedrock model, you can [create or update an agent](https://kagent.dev/docs/kagent/getting-started/first-agent) to use this model configuration. |
0 commit comments