fix(provider): add support for jp. prefix in Amazon Bedrock cross-region inference profiles #6916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using Amazon Bedrock with the
jp.cross-region inference profile prefix (e.g.,jp.anthropic.claude-sonnet-4-5-20250929-v1:0), OpenCode incorrectly adds an additional region prefix, causing the model invocation to fail.Currently, OpenCode only skips region prefixing for models starting with
global., but AWS Bedrock also provides ajp.(Japan) cross-region inference profile, which is required for using certain models in theap-northeast-1(Tokyo) region.Example
When configuring:
{ "model": "amazon-bedrock/jp.anthropic.claude-sonnet-4-5-20250929-v1:0" }With
AWS_REGION=ap-northeast-1, OpenCode currently transforms this toapac.jp.anthropic.claude-sonnet-4-5-20250929-v1:0, which is invalid.Solution
Add
jp.to the list of prefixes that skip automatic region prefixing, alongside the existingglobal.prefix.Changes
packages/opencode/src/provider/provider.tsto recognizejp.prefix as a cross-region inference profile prefix that should not have additional region prefixes added.Background
The
jp.prefix is a Japan-specific cross-region inference profile provided by AWS Bedrock. Unlike theapac.prefix (which covers broader Asia Pacific regions), thejp.prefix routes requests specifically to the Japan (Tokyo) region infrastructure.Some models like Claude Sonnet 4.5 are available with the
jp.inference profile but not with theapac.profile, making this fix necessary for users in the Japan region.Testing
Tested with:
jp.anthropic.claude-sonnet-4-5-20250929-v1:0ap-northeast-1