[PR #6332] fix(bedrock): support region and bearer token configuration #11841

Closed
opened 2026-02-16 18:16:46 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6332

State: closed
Merged: Yes


Fixes #5812

Add support for configuring Amazon Bedrock provider region and bearer token through opencode.json and auth.json.

Region Configuration

The amazon-bedrock provider now respects the region option from config (opencode.json) with proper precedence:

  1. options.region from opencode.json (highest priority)
  2. AWS_REGION environment variable
  3. Default us-east-1 fallback

Users can now configure:

{
  "provider": {
    "amazon-bedrock": {
      "options": { "region": "eu-west-1" }
    }
  }
}

Bearer Token from Auth

The provider now checks ~/.local/share/opencode/auth.json for bearer tokens with precedence:

  1. AWS_BEARER_TOKEN_BEDROCK environment variable (if set)
  2. Bearer token from auth.json (if available)

This allows users to configure their Bedrock bearer token once and have it automatically used by OpenCode.

Changes

  • Remove Promise.all() from env var retrieval and add Auth.get() check for bearer tokens
  • Implement bearer token precedence: env var first, then auth.json
  • Rename region to defaultRegion to clarify it's the default used when no config override exists
  • Add region variable in getModel() for resolved region with config precedence
  • Update getModel() parameter from _options to options (was previously ignored)
  • Add region resolution precedence comment and tests for region and auth configuration scenarios
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6332 **State:** closed **Merged:** Yes --- Fixes #5812 Add support for configuring Amazon Bedrock provider region and bearer token through opencode.json and auth.json. ### Region Configuration The amazon-bedrock provider now respects the `region` option from config (opencode.json) with proper precedence: 1. `options.region` from opencode.json (highest priority) 2. `AWS_REGION` environment variable 3. Default `us-east-1` fallback Users can now configure: ```json { "provider": { "amazon-bedrock": { "options": { "region": "eu-west-1" } } } } ``` ### Bearer Token from Auth The provider now checks `~/.local/share/opencode/auth.json` for bearer tokens with precedence: 1. `AWS_BEARER_TOKEN_BEDROCK` environment variable (if set) 2. Bearer token from auth.json (if available) This allows users to configure their Bedrock bearer token once and have it automatically used by OpenCode. ### Changes - Remove `Promise.all()` from env var retrieval and add `Auth.get()` check for bearer tokens - Implement bearer token precedence: env var first, then auth.json - Rename `region` to `defaultRegion` to clarify it's the default used when no config override exists - Add `region` variable in `getModel()` for resolved region with config precedence - Update `getModel()` parameter from `_options` to `options` (was previously ignored) - Add region resolution precedence comment and tests for region and auth configuration scenarios
yindo added the pull-request label 2026-02-16 18:16:46 -05:00
yindo closed this issue 2026-02-16 18:16:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11841