Using AWS Bedrock with opencode

Setup your opencode CLI to work with AWS Bedrock foundational models

On this page

opencode is a AI coding agent built for the terminal.

It's extensible nature means that we can configure our own models. This is where AWS Bedrock, an AWS offering for foundational models and agent tools, comes in.

Using AWS Bedrock with opencode

opencode (v1.0.68) will automatically enable AWS Bedrock model selection within the CLI if your terminal environment exports the expected enviornment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION). Personally, I make use of aws-vault for managing this.

opencode Bedrock models
opencode Bedrock models

AWS Bedrock Foundational models

For some foundational models (such as Claude models), you need to head to Bedrock on the AWS console and submit the use cases for Anthropic.

Use case form for Anthropic
Use case form for Anthropic

This is a requirement for usage of those models in opencode.

Photo credit: johnnyb803