opencode icon indicating copy to clipboard operation
opencode copied to clipboard

AWS Bedrock Custom Inference Profiles Not Supported - Getting AI_APICallError: Forbidden

Open ncino-chamby9 opened this issue 3 months ago • 8 comments

Summary OpenCode fails to work with custom AWS Bedrock inference profiles, returning AI_APICallError: Forbidden errors. The tool appears to only support direct foundational model access rather than custom inference profiles. Environment

Tool: OpenCode Provider: Amazon Bedrock AWS Region: us-east-1 Inference Profile Type: Custom/Application inference profile

Expected Behavior OpenCode should be able to utilize AWS Bedrock custom inference profiles just like direct foundational model access.

Actual Behavior When attempting to use a custom AWS Bedrock inference profile, OpenCode returns: AI_APICallError: Forbidden The same AWS credentials and inference profile work correctly with:

AWS CLI (aws bedrock-runtime invoke-model) Direct API calls to Bedrock Other Bedrock-compatible tools (Claude Code)

Root Cause Analysis The issue appears to stem from OpenCode making API calls that expect direct foundational model ARNs rather than inference profile ARNs. Custom inference profiles use a different ARN format and may require different API endpoints or permissions. Direct Model ARN Format: arn:aws:bedrock:[region]::foundation-model/[model-id] Inference Profile ARN Format: arn:aws:bedrock:[region]:[account]:application-inference-profile/[profile-name] Steps to Reproduce

Create a custom AWS Bedrock inference profile in your AWS account Configure OpenCode to use the inference profile ARN as the model identifier Attempt to make any AI-assisted code generation request Observe the AI_APICallError: Forbidden error

Workaround: None

Proposed Solution OpenCode should be updated to:

Detect inference profile ARNs and route requests appropriately Support both model types transparently to the user Use correct API endpoints for inference profile invocations Handle authentication for custom profiles (which may require different IAM permissions)

Additional Context

AWS Bedrock inference profiles are a supported feature for enterprise customers Other AI development tools (like Claude Code) have successfully implemented support for both direct models and inference profiles This affects teams using AWS Bedrock in production environments where inference profiles are standard practice

Requested Priority High - This blocks adoption of OpenCode as a tool in our business

ncino-chamby9 avatar Sep 23 '25 11:09 ncino-chamby9